config

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMySQLPort = 3306

Variables

This section is empty.

Functions

func Reset

func Reset()

Reset sets the initial state of the configuration instance

Types

type Configuration

type Configuration struct {
	// contains filtered or unexported fields
}

Configuration struct stores the readFileNames and points to the settings which are the configuration parameters used in the application. see ConfigurationSettings for the available settings. Read file names are also stored to allow configuration reloading.

func Instance

func Instance() *Configuration

Instance returns the global instance of Configuration

func (*Configuration) Read

func (config *Configuration) Read(fileNames ...string) error

Read reads configuration from all given files, in order of input. Each file can override the properties of the previous files Initially, the settings are the defult ones defined by newConfigurationSettings

func (*Configuration) Reload

func (config *Configuration) Reload() error

Reload re-reads configuration from last used files

type ConfigurationSettings

type ConfigurationSettings struct {
	ListenPort      int
	RaftBind        string
	RaftDataDir     string
	DefaultRaftPort int      // if a RaftNodes entry does not specify port, use this one
	RaftNodes       []string // Raft nodes to make initial connection with
	MemcacheServers []string // if given, freno will report to aggregated values to given memcache
	MemcachePath    string   // use as prefix to metric path in memcache key, e.g. if `MemcachePath` is "myprefix" the key would be "myprefix/mysql/maincluster". Default: "freno"
	Stores          StoresSettings
}

ConfigurationSettings models a set of configurable values, that can be provided by the user via one or several JSON formatted files.

Some of the settinges have reasonable default values, and some other (like database credentials) are strictly expected from user.

func Settings

func Settings() *ConfigurationSettings

Settings returns the settings of the global instance of Configuration

type HAProxyConfigurationSettings

type HAProxyConfigurationSettings struct {
	Host     string
	Port     int
	PoolName string
}

func (*HAProxyConfigurationSettings) IsEmpty

func (settings *HAProxyConfigurationSettings) IsEmpty() bool

type MySQLClusterConfigurationSettings

type MySQLClusterConfigurationSettings struct {
	User              string  // override MySQLConfigurationSettings's, or leave empty to inherit those settings
	Password          string  // override MySQLConfigurationSettings's, or leave empty to inherit those settings
	MetricQuery       string  // override MySQLConfigurationSettings's, or leave empty to inherit those settings
	ThrottleThreshold float64 // override MySQLConfigurationSettings's, or leave empty to inherit those settings
	Port              int     // Specify if different than 3306 or if different than specified by MySQLConfigurationSettings
	IgnoreHostsCount  int     // Number of hosts that can be skipped/ignored even on error or on exceeding theesholds

	HAProxySettings     HAProxyConfigurationSettings // If list of servers is to be acquired via HAProxy, provide this field
	StaticHostsSettings StaticHostsConfigurationSettings
}

type MySQLConfigurationSettings

type MySQLConfigurationSettings struct {
	User              string
	Password          string
	MetricQuery       string
	ThrottleThreshold float64
	Port              int // Specify if different than 3306; applies to all clusters
	IgnoreHostsCount  int // Number of hosts that can be skipped/ignored even on error or on exceeding theesholds

	Clusters map[string](*MySQLClusterConfigurationSettings) // cluster name -> cluster config
}

type StaticHostsConfigurationSettings

type StaticHostsConfigurationSettings struct {
	Hosts []string // a host can be "hostname" or "hostname:port"
}

func (*StaticHostsConfigurationSettings) IsEmpty

func (settings *StaticHostsConfigurationSettings) IsEmpty() bool

type StoresSettings

type StoresSettings struct {
	MySQL MySQLConfigurationSettings // Any and all MySQL setups go here

}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL