Documentation ¶
Index ¶
- Variables
- func Load(in string) error
- func LoadFile(in string) error
- func OnConfigChange(run func(in fsnotify.Event))
- func Set(fp string, l log.Logger) error
- func SetConfig(newConf *Config)
- func SetConfigPath(in string)
- func SetConfigPermissions(perm os.FileMode)
- func SetLogger(l log.Logger)
- func Show()
- func WatchConfig()
- func Write() error
- type BasicAuthentication
- type Config
- type EtcdConfig
- type GlobalConfig
- type Manager
- func (m *Manager) Get() *Config
- func (m *Manager) Load(in string) error
- func (m *Manager) LoadFile(in string) error
- func (m *Manager) OnConfigChange(run func(in fsnotify.Event))
- func (m *Manager) Set(fp string, l log.Logger) error
- func (m *Manager) SetConfig(newConf *Config)
- func (m *Manager) SetConfigPath(in string)
- func (m *Manager) SetConfigPermissions(perm os.FileMode)
- func (m *Manager) SetLogger(l log.Logger)
- func (m *Manager) Show()
- func (m *Manager) WatchConfig()
- func (m *Manager) Write() error
- type Secret
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultConfig is the default top-level configuration. DefaultConfig = Config{ GlobalConfig: DefaultGlobalConfig, EtcdConfig: DefaultEtcdConfig, } // DefaultGlobalConfig is the default global configuration. DefaultGlobalConfig = GlobalConfig{ RemoteHostPattern: ".*", BasicAuthentication: BasicAuthentication{}, } // DefaultEtcdConfig is the default Etcd configuration. DefaultEtcdConfig = EtcdConfig{ Endpoints: []string{"127.0.0.1:2379"}, DialTimeout: etcdDefaultDialTimeout, DialKeepAliveTime: etcdDefaultKeepAliveTime, DialKeepAliveTimeout: etcdDefaultKeepAliveTimeOut, } )
Functions ¶
func OnConfigChange ¶
OnConfigChange defines the function be called when config file was change.
func SetConfig ¶
func SetConfig(newConf *Config)
SetConfig updates the value of configuration. newConf should be a copy of m.config instance.
func SetConfigPermissions ¶
SetConfigPermissions sets the permissions for the config file.
Types ¶
type BasicAuthentication ¶
type BasicAuthentication struct { // Usename, Password to implement HTTP basic authentication Username string `yaml:"username"` Password Secret `yaml:"password"` }
BasicAuthentication - HTTP Basic authentication.
type Config ¶
type Config struct { GlobalConfig GlobalConfig `yaml:"global"` EtcdConfig EtcdConfig `yaml:"etcd"` }
Config is the top-level configuration for Faythe's config file.
func (*Config) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface
type EtcdConfig ¶
type EtcdConfig struct { // Endpoints is a list of URLs. Endpoints []string `yaml:"endpoints"` // AutoSyncInterval is the interval to update endpoints with its latest members. // 0 disables auto-sync. By default auto-sync is disabled. AutoSyncInterval time.Duration `yaml:"auto_sync_interval,omitempty"` // DialTimeout is the timeout for failing to establish a connection. DialTimeout time.Duration `yaml:"dial_timeout,omitempty"` // DialKeepAliveTime is the time after which client pings the server to see if // transport is alive. DialKeepAliveTime time.Duration `yaml:"dial_keep_alive_time,omitempty"` // DialKeepAliveTimeout is the time that the client waits for a response for the // keep-alive probe. If the response is not received in this time, the connection is closed. DialKeepAliveTimeout time.Duration `yaml:"dial_keep_alive_timeout,omitempty"` // MaxCallSendMsgSize is the client-side request send limit in bytes. // If 0, it defaults to 2.0 MiB (2 * 1024 * 1024). // Make sure that "MaxCallSendMsgSize" < server-side default send/recv limit. // ("--max-request-bytes" flag to etcd or "embed.Config.MaxRequestBytes"). MaxCallSendMsgSize int `yaml:"max_call_send_msg_size,omitempty"` // MaxCallRecvMsgSize is the client-side response receive limit. // If 0, it defaults to "math.MaxInt32", because range response can // easily exceed request send limits. // Make sure that "MaxCallRecvMsgSize" >= server-side default send/recv limit. // ("--max-request-bytes" flag to etcd or "embed.Config.MaxRequestBytes"). MaxCallRecvMsgSize int `yaml:"max_call_recv_msg_size,omitempty"` // TLS holds the client secure credentials, if any. TLS *tls.Config `yaml:"tls,omitempty"` // Username is a user name for authentication. Username string `yaml:"username,omitempty"` // Password is a password for authentication. Password Secret `yaml:"password,omitempty"` // RejectOldCluster when set will refuse to create a client against an outdated cluster. RejectOldCluster bool `yaml:"reject_old_cluster,omitempty"` // PermitWithoutStream when set will allow client to send keepalive pings to server without any active streams(RPCs). PermitWithoutStream bool `yaml:"permit_without_stream,omitempty"` }
EtcdConfig stores Etcd related configurations.
func (*EtcdConfig) UnmarshalYAML ¶
func (c *EtcdConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface
type GlobalConfig ¶
type GlobalConfig struct { // RemoteHostPattern can define an optional regexp pattern to be matched: // // - {name} matches anything until the next dot. // // - {name:pattern} matches the given regexp pattern. RemoteHostPattern string `yaml:"remote_host_pattern,omitempty"` // BasicAuthentication - HTTP Basic authentication. BasicAuthentication BasicAuthentication `yaml:"basic_auth,omitempty"` }
GlobalConfig configures values that are used to config Faythe HTTP server
func (*GlobalConfig) UnmarshalYAML ¶
func (c *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface
type Manager ¶
type Manager struct { Config *Config // contains filtered or unexported fields }
Manager is a configuration manager. It maintains a global configuration, fetchs values to populate.
func (*Manager) OnConfigChange ¶
OnConfigChange defines the function be called when config file was change.
func (*Manager) SetConfig ¶
SetConfig updates the value of configuration. newConf should be a copy of m.config instance.
func (*Manager) SetConfigPath ¶
SetConfigPath sets the path of config file
func (*Manager) SetConfigPermissions ¶
SetConfigPermissions sets the permissions for the config file.
func (*Manager) Show ¶
func (m *Manager) Show()
Show returns the represent of Config. For debug purpose only
func (*Manager) WatchConfig ¶
func (m *Manager) WatchConfig()
WatchConfig detects file changes and reloads config.
type Secret ¶
type Secret string
Secret special type for storing secrets
func (Secret) MarshalYAML ¶
MarshalYAML implements the yaml.Marshaler interface for Secrets.
func (*Secret) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface for Secrets.