Documentation ¶
Overview ¶
Package config , actually copied from github.com/elastic/beats
Index ¶
- func NewFlagOverwrite(set *flag.FlagSet, config *Config, name, path, def, usage string) *string
- type ClusterConfig
- type Config
- func LoadFile(path string) (*Config, error)
- func LoadFiles(paths ...string) (*Config, error)
- func MergeConfigs(cfgs ...*Config) (*Config, error)
- func NewConfig() *Config
- func NewConfigFrom(from interface{}) (*Config, error)
- func NewConfigWithYAML(in []byte, source string) (*Config, error)
- func NewFlagConfig(set *flag.FlagSet, def *Config, name string, usage string) *Config
- func (c *Config) Bool(name string, idx int) (bool, error)
- func (c *Config) Child(name string, idx int) (*Config, error)
- func (c *Config) CountField(name string) (int, error)
- func (c *Config) Enabled(defaultV bool) bool
- func (c *Config) Float(name string, idx int) (float64, error)
- func (c *Config) GetFields() []string
- func (c *Config) HasField(name string) bool
- func (c *Config) Int(name string, idx int) (int64, error)
- func (c *Config) IsArray() bool
- func (c *Config) IsDict() bool
- func (c *Config) Merge(from interface{}) error
- func (c *Config) Path() string
- func (c *Config) PathOf(field string) string
- func (c *Config) SetBool(name string, idx int, value bool) error
- func (c *Config) SetChild(name string, idx int, value *Config) error
- func (c *Config) SetFloat(name string, idx int, value float64) error
- func (c *Config) SetInt(name string, idx int, value int64) error
- func (c *Config) SetString(name string, idx int, value string) error
- func (c *Config) String(name string, idx int) (string, error)
- func (c *Config) Unpack(to interface{}) error
- type LoggingConfig
- type Namespace
- type NetworkConfig
- type NodeConfig
- type PathConfig
- type RPCConfig
- type Rule
- type Rules
- type SystemConfig
- type TLSConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClusterConfig ¶
type ClusterConfig struct { Enabled bool `config:"enabled"` Name string `config:"name"` MinimumNodes int `config:"minimum_nodes"` Seeds []string `config:"seeds"` RPCConfig RPCConfig `config:"rpc"` BoradcastConfig NetworkConfig `config:"broadcast"` }
ClusterConfig stores cluster settings
type Config ¶
type Config ucfg.Config
Config object to store hierarchical configurations into. See https://godoc.org/github.com/elastic/go-ucfg#Config
func MergeConfigs ¶
MergeConfigs just merge configs together
func NewConfigFrom ¶
NewConfigFrom get config instance
func NewConfigWithYAML ¶
NewConfigWithYAML load config from yaml
func NewFlagConfig ¶
NewFlagConfig will use flags
func (*Config) Bool ¶
Bool reads a boolean setting returning an error if the setting has no boolean value.
func (*Config) Child ¶
Child returns a child configuration or an error if the setting requested is a primitive value only.
func (*Config) CountField ¶
CountField returns number of entries in a table or 1 if entry is a primitive value. Primitives settings can be handled like a list with 1 entry.
func (*Config) Float ¶
Float reads a float64 value returning an error if the setting is not a float value or the primitive value is not convertible to float.
func (*Config) Int ¶
Int reads an int64 value returning an error if the setting is not integer value, the primitive value is not convertible to int or a conversion would create an integer overflow.
func (*Config) Path ¶
Path gets the absolute path of c separated by sep. If c is a root-Config an empty string will be returned.
func (*Config) PathOf ¶
PathOf gets the absolute path of a potential setting field in c with name separated by sep.
func (*Config) SetBool ¶
SetBool sets a boolean primitive value. An error is returned if the new name is invalid.
func (*Config) SetChild ¶
SetChild adds a sub-configuration. An error is returned if the name is invalid.
func (*Config) SetFloat ¶
SetFloat sets an floating point primitive value. An error is returned if the name is invalid.
func (*Config) SetInt ¶
SetInt sets an integer primitive value. An error is returned if the new name is invalid.
func (*Config) SetString ¶
SetString sets string value. An error is returned if the name is invalid.
type LoggingConfig ¶
type LoggingConfig struct { RealtimePushEnabled bool `json:"realtime"` LogLevel string `json:"log_level"` PushLogLevel string `json:"push_log_level"` FuncFilterPattern string `json:"func_pattern"` FileFilterPattern string `json:"file_pattern"` MessageFilterPattern string `json:"message_pattern"` }
LoggingConfig object to store logging related settings
type Namespace ¶
Namespace storing at most one configuration section by name and sub-section.
type NetworkConfig ¶
type NetworkConfig struct { Host string `config:"host"` Port string `config:"port"` Binding string `config:"binding"` }
NetworkConfig stores network settings
func (NetworkConfig) GetBindingAddr ¶
func (cfg NetworkConfig) GetBindingAddr() string
type NodeConfig ¶
type NodeConfig struct {
Name string `config:"name"`
}
NodeConfig stores node settings
type PathConfig ¶
type PathConfig struct { Data string `config:"data"` Log string `config:"logs"` Cert string `config:"certs"` }
PathConfig stores path settings
type RPCConfig ¶
type RPCConfig struct { TLSConfig TLSConfig `config:"tls"` NetworkConfig NetworkConfig `config:"network"` }
type Rule ¶
type Rule struct { Contain []string `config:"contain"` Prefix []string `config:"prefix"` Suffix []string `config:"suffix"` }
Rule is container of rules
type Rules ¶
type Rules struct { Should *Rule `config:"should"` Must *Rule `config:"must"` MustNot *Rule `config:"must_not"` }
Rules defines two fields, Should means any of the rules matched will be work Must means some rule must match MustNot means some rule must not match
type SystemConfig ¶
type SystemConfig struct { ClusterConfig ClusterConfig `config:"cluster"` NodeConfig NodeConfig `config:"node"` PathConfig PathConfig `config:"path"` CookieSecret string `config:"cookie_secret"` AllowMultiInstance bool `config:"allow_multi_instance"` MaxNumOfInstance int `config:"max_num_of_instances"` Modules []*Config `config:"modules"` Plugins []*Config `config:"plugins"` }
SystemConfig is a high priority config, init from the environment or startup, can't be changed on the fly, need to restart to make config apply