Documentation ¶
Overview ¶
Package config defines a series of devspore redis configuration, include configuration from yaml and remote etcd.
Index ¶
Constants ¶
const ( ServerTypeCluster = "cluster" ServerTypeNormal = "normal" ServerTypeMasterSlave = "master-slave" ServerTypeSentinel = "sentinel" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncRemotePoolConfiguration ¶ added in v1.0.0
type AsyncRemoteWrite ¶ added in v1.0.0
type AsyncRemoteWrite struct {
RetryTimes int `yaml:"retryTimes"`
}
type Configuration ¶
type Configuration struct { Props *mas.PropertiesConfiguration `yaml:"props"` EtcdConfig *etcd.EtcdConfiguration `yaml:"etcd"` RedisConfig *RedisConfiguration `yaml:"redis"` RouteAlgorithm string `yaml:"routeAlgorithm"` Active string `yaml:"active"` Chaos *mas.InjectionProperties `yaml:"chaos"` }
Configuration is used to create DevsporeClient
func LoadConfiguration ¶
func LoadConfiguration(yamlFilePath string) (*Configuration, error)
LoadConfiguration generate Configuration form yaml configuration file.
func (*Configuration) AssignRemoteConfig ¶
func (c *Configuration) AssignRemoteConfig()
AssignRemoteConfig will combine local configuration and remote configuration.
func (*Configuration) ComputeNearestServer ¶
func (c *Configuration) ComputeNearestServer()
ComputeNearestServer compute nearest redis server according to server's cloud, region and az.
func (*Configuration) ConvertServerConfiguration ¶
func (c *Configuration) ConvertServerConfiguration()
ConvertServerConfiguration convert devspore server configuration to go-redis Options or cluster Options.
func (*Configuration) OnChanged ¶
func (c *Configuration) OnChanged(active string)
OnChanged when remote etcd active key changed, change the Configuration's active server.
type Listener ¶
type Listener interface {
OnChanged(active string)
}
Listener is the interface for watching etcd active key changes.
type RedisConfiguration ¶
type RedisConfiguration struct { RedisGroupName string `yaml:"redisGroupName"` UserName string `yaml:"useName"` Nearest string `yaml:"nearest"` Servers map[string]*ServerConfiguration `yaml:"servers"` ConnectionPoolConfig *RedisConnectionPoolConfiguration `yaml:"connectionPool"` AsyncRemoteWrite *AsyncRemoteWrite `yaml:"asyncRemoteWrite"` AsyncRemotePoolConfiguration *AsyncRemotePoolConfiguration `yaml:"asyncRemotePool"` }
RedisConfiguration defines a series of redis configuration in yaml file.
type RedisConnectionPoolConfiguration ¶
type RedisConnectionPoolConfiguration struct {
Enable bool `yaml:"enable"`
}
type RemoteConfigurationLoader ¶
type RemoteConfigurationLoader struct {
// contains filtered or unexported fields
}
RemoteConfigurationLoader to load remote configuration from etcd
func NewRemoteConfigurationLoader ¶
func NewRemoteConfigurationLoader(props *mas.PropertiesConfiguration, etcdConfiguration *etcd.EtcdConfiguration) *RemoteConfigurationLoader
NewRemoteConfigurationLoader create a loader to load remote configuration
func (*RemoteConfigurationLoader) AddRouterListener ¶
func (l *RemoteConfigurationLoader) AddRouterListener(listener Listener)
AddRouterListener add a listener
func (*RemoteConfigurationLoader) GetConfiguration ¶
func (l *RemoteConfigurationLoader) GetConfiguration() *RemoteRedisConfiguration
GetConfiguration from etcd, which contains route algorithm, active server and all redis servers.
func (*RemoteConfigurationLoader) Init ¶
func (l *RemoteConfigurationLoader) Init()
Init etcd start watch activeKey
type RemoteRedisConfiguration ¶
type RemoteRedisConfiguration struct { RouteAlgorithm string Active string Servers map[string]*ServerConfiguration }
RemoteRedisConfiguration is set in remote etcd, contains active server, routeAlgorithm and redis servers.
func NewRemoteRedisConfiguration ¶
func NewRemoteRedisConfiguration(routeAlgorithm, active, serversStr string) *RemoteRedisConfiguration
NewRemoteRedisConfiguration create a RemoteRedisConfiguration with etcd configuration strings .
type ServerConfiguration ¶
type ServerConfiguration struct { Hosts string `yaml:"hosts"` Password string `yaml:"password"` Type string `yaml:"type"` // cluster, normal, sentinel Cloud string `yaml:"cloud"` Region string `yaml:"region"` Azs string `yaml:"azs"` Db int `yaml:"db"` // default 0 MaxAttempts int `yaml:"maxAttempts"` Timeout int `yaml:"timeout"` SentinelPassword string `yaml:"sentinelPassword"` // sentinel opt MasterName string `yaml:"masterName"` // sentinel opt ConnectionPool *ServerConnectionPoolConfiguration `yaml:"pool"` ClusterOptions *redis.ClusterOptions FailoverOptions *redis.FailoverOptions Options *redis.Options }
ServerConfiguration contains yaml redis server configuration, go-redis Options and ClusterOptions(when type is cluster).
type ServerConnectionPoolConfiguration ¶
type ServerConnectionPoolConfiguration struct { MaxTotal int `yaml:"maxTotal"` MaxIdle int `yaml:"maxIdle"` MinIdle int `yaml:"minIdle"` MaxWaitMillis int `yaml:"maxWaitMillis"` TimeBetweenEvictionRunsMillis int `yaml:"timeBetweenEvictionRunsMillis"` Lifo bool `yaml:"lifo"` }
ServerConnectionPoolConfiguration connection pool configuration