Documentation ¶
Overview ¶
Package config has three parts:
config.go: A really simple key-value store for configs. Stores all configs as string values internally, but has getters like GetInt, GetDuration, etc.
defaults.go: For now it is concidered a best practise to set all default values here and write documentation for them.
dtoconf.go: Interface and functions used to pass over configuration and state when replacing a node.
The application can chose to provide a configuration-system on top of this simple config. The easiest would be to have a ini-based config-system like the one found in goxos/kvs/kvsd
Index ¶
- Constants
- type Config
- func (c *Config) CloneToKeyValueMap() map[string]string
- func (c *Config) GetBool(key string, defaultVal bool) bool
- func (c *Config) GetDuration(key string, defaultVal time.Duration) time.Duration
- func (c *Config) GetInt(key string, defaultVal int) int
- func (c *Config) GetNodeList(key string) ([]grp.Node, error)
- func (c *Config) GetNodeMap(key string) (grp.NodeMap, error)
- func (c *Config) GetString(key, defaultVal string) string
- func (c *Config) Set(key, value string)
- type TransferWrapper
Constants ¶
const ( // REQUIRED! // nodes: [id:hostname:paxosPort:clientPort], ... // Defines all nodes that should run. Comma separated list. DefNodes = "" // protocol: MultiPaxos | ParallelPaxos | BatchPaxos | AuthenticatedBC | ReliableBC DefProtocol = "MultiPaxos" // alpha: int // Alpha value used for pipelining DefAlpha = 3 // batchMaxSize: int // Regular batching of requests before they are sent through paxos DefBatchMaxSize = 1 // batchTimeout: duration // Regular batching of requests before they are sent through paxos DefBatchTimeout = 3000 * time.Microsecond // failureHandlingType: None | AReconfiguration | Reconfiguration | LiveReplacement DefFailureHandlingType = "None" // hbEmitterInterval: duration // How frequently do we emit heartbeats? DefHbEmitterInterval = 500 * time.Millisecond // fdTimeoutInterval: duration // How frequently does the FD module check for liveness? DefFdTimeoutInterval = 1000 * time.Millisecond // fdDeltaIncrease: duration // If node is falsely detected as crashed, how much do we increase // timeout by? DefFdDeltaIncrease = 250 * time.Millisecond // parallelPaxosProposers: int // Number of parallel proposers to run DefParallelPaxosProposers = 2 // parallelPaxosAcceptors: int // Number of parallel acceptors to run DefParallelPaxosAcceptors = 2 // parallelPaxosLearners: int // Number of parallel learners to run DefParallelPaxosLearners = 2 // parallelPaxosLearners: duration // Maximum period of inactivity before batching occurs anyway DefBatchPaxosTimeout = 1000 * time.Millisecond // parallelPaxosLearners: int // Maximum number of requests in a batch DefBatchPaxosMaxSize = 100 // nodeInitReplicaProvider: Disabled | Mock | Kvs // NodeInit specific settings DefNodeInitReplicaProvider = "Disabled" // nodeInitStandbys: [hostname:paxosPort:clientPort], ... // NodeInit specific settings DefNodeInitStandbys = "" // activationTimeout: int (milliseconds) DefActivationTimeout = 3000 // LRStrategy: int (1 | 2 | 3) // Live Replacement strategy DefLRStrategy = 2 // LRExpRndSleep: duration // If != 0, enable 0.5 prob for sleeping this duration before connecting to replacer DefLRExpRndSleep = 0 // throughputSamplingInterval: duration // How often should the server log its throughput. // 0 turns off throughput logging. DefThroughputSamplingInterval = time.Duration(0) DefLivenessValues = "100,50,250" // Dunno if this is used: MinNrNodes = 3 // configKeysPath: string // Path to keys used by authentication manager DefConfigKeysPath = "config-keys.json" // nrOfPublications: int // Number of publications to be published DefNrOfPublications = 100 // publicationPayloadSize: int // Size of each publication in bytes DefPublicationPayloadSize = 32 )
Default configuration settings for Goxos
const ( // cycleListMax: int // How many times should we loop through the node list when trying to tcp connect? DefCycleListMax = 3 // cycleNodesWait: int (milliseconds) // How long should we wait between each connection attempt in tcp connect? DefCycleNodesWait = 1000 * time.Millisecond // dialTimeout: int (milliseconds) // What should the timeout be when dialing a replica in tcp connect? DefDialTimeout = 500 * time.Millisecond // writeTimeout: int (milliseconds) // What should the timeout be when writing/sending requests? DefWriteTimeout = 20000 * time.Millisecond // readTimeout: int (seconds) // What should the timeout be when reading responses? DefReadTimeout = 20 * time.Second // awaitResponseTimeout: int (seconds) // How long should we wait before timing out (wihtout a response) when sending requests? DefAwaitResponseTimeout = 60 * time.Second )
Default configuration settings for the Goxos client library
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
The Config holds a map of config values by their keys/names. They are all stored as strings and parsed on read time only. Currently there are four built in types:
`string`: (GetString) Returns the config value as a string. This can never fail.
`int`: (GetInt) Uses strconv.Atoi to parse the value and return an int.
`duration`: (GetDuration) Uses time.ParseDuration to parse the value and return a duration. That means that you should set duration configs like "xxx us/ms/s/h/etc."
`bool`: (GetBool) Uses strconv.ParseBool to read config vars like true/t/1 or false/f/0
`nodemap`: (GetNodeMap) Returns a grp.NodeMap parsed from a format like ([id:hostname:paxosPort:clientPort], ...)
`nodelist`: (GetNodeList) Returns a []grp.Node parsed from a format similar to `nodemap`, just without the ids. (used for the config `nodeInitStandbys`)
When a value COULD NOT BE PARSED at runtime, Cofig emits a warning (with glog) and returns the given DEFAULT VALUE.
We should prefer to keep this Config-system as simple as possible. If you really need another type than the ones that Config gives you, you should rather use GetString and parse it where you use it. And if you need an uint, you should rather cast the int given from GetInt.
func (*Config) CloneToKeyValueMap ¶
Clones the config with all the values.
func (*Config) GetBool ¶
Returns the config as an bool. If the config is not set, the supplied default value is returned. If the config is not possible to parse as an int (strconv.ParseBool), the default value is returned and an warning message is written to glog.
func (*Config) GetDuration ¶
Returns the config as an time.Duration. If the config is not set, the supplied default value is returned. If the config is not possible to parse as an int (time.ParseDuration), the default value is returned and an warning message is written to glog.
func (*Config) GetInt ¶
Returns the config as an int. If the config is not set, the supplied default value is returned. If the config is not possible to parse as an int (strconv.Atoi), the default value is returned and an warning message is written to glog.
func (*Config) GetNodeList ¶
Parses a node list: ([hostname:paxosPort:clientPort], ...) into a []grp.Node.
This one takes no default values. The function returns an descriptive error if the value is unreadable. But an empty value gives an empty list.
func (*Config) GetNodeMap ¶
Parses a node map: ([id:hostname:paxosPort:clientPort], ...) into a grp.NodeMap.
This one takes no default values. The node map in the config `node` is always required anyway, and the function returns an descriptive error instead.