Documentation
¶
Overview ¶
Package config defines a series of configuration, include yaml configuration, remote configuration and integration configuration which contains the above two configurations.
Index ¶
- func ValidateClusterConfiguration(configuration *ClusterConfiguration) error
- type ClusterConfiguration
- type DataSourceConfiguration
- type IntegrationClusterConfiguration
- type NodeConfiguration
- type RemoteClusterConfiguration
- type RemoteDataSourceConfiguration
- type RetryConfiguration
- type RouterConfiguration
- type RouterConfigurationListener
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateClusterConfiguration ¶
func ValidateClusterConfiguration(configuration *ClusterConfiguration) error
ValidateClusterConfiguration returns err if clusterConfiguration is invalid
Types ¶
type ClusterConfiguration ¶
type ClusterConfiguration struct {
Props *mas.PropertiesConfiguration `yaml:"props"`
EtcdConfig *etcd.EtcdConfiguration `yaml:"etcd"`
RouterConfig *RouterConfiguration `yaml:"router"`
DataSource map[string]*DataSourceConfiguration `yaml:"datasource"`
Chaos *mas.InjectionProperties `yaml:"chaos"`
}
ClusterConfiguration yaml cluster configuration entity
func Unmarshal ¶
func Unmarshal(yamlFilePath string) (*ClusterConfiguration, error)
Unmarshal yamlConfigFile to *ClusterConfiguration
type DataSourceConfiguration ¶
type DataSourceConfiguration struct {
URL string `yaml:"url"` // dsn format, `protocol(address)/dbname?param=value`
Username string `yaml:"username"`
Password string `yaml:"password"`
Region string
Server string
Schema string
}
DataSourceConfiguration contains yaml datasource configuration and remote datasource configuration
type IntegrationClusterConfiguration ¶
type IntegrationClusterConfiguration struct {
ClusterConfiguration *ClusterConfiguration
RemoteClusterConfiguration *RemoteClusterConfiguration
}
IntegrationClusterConfiguration combine yaml cluster datasource configuration and etcd remote cluster configuration
func (*IntegrationClusterConfiguration) GetDataSource ¶
func (c *IntegrationClusterConfiguration) GetDataSource() map[string]*DataSourceConfiguration
GetDataSource Get datasource configuration map through merge local cluster configuration and remote cluster configuration.
func (*IntegrationClusterConfiguration) GetRouterConfig ¶
func (c *IntegrationClusterConfiguration) GetRouterConfig() *RouterConfiguration
GetRouterConfig Get router configuration map through merge local cluster configuration and remote cluster configuration.
type NodeConfiguration ¶
type NodeConfiguration struct {
Weight int `yaml:"weight"`
Master string `yaml:"master"`
LoadBalance string `yaml:"loadBalance"`
Slaves []string `yaml:"slaves"`
}
NodeConfiguration yaml node configuration entity
type RemoteClusterConfiguration ¶
type RemoteClusterConfiguration struct {
DataSources map[string]*RemoteDataSourceConfiguration
RouterConfig *RouterConfiguration
}
RemoteClusterConfiguration contains datasources map and router config
func NewRemoteClusterConfiguration ¶
func NewRemoteClusterConfiguration(dataSourceConfigStr string, routerConfigStr string) *RemoteClusterConfiguration
NewRemoteClusterConfiguration with remote datasourceConfig and routerConfig
type RemoteDataSourceConfiguration ¶
type RemoteDataSourceConfiguration struct {
Server string
Schema string
Username string
Password string
Region string
Cloud string
}
RemoteDataSourceConfiguration etcd remote datasource configuration
type RetryConfiguration ¶
RetryConfiguration yaml retry configuration entity
type RouterConfiguration ¶
type RouterConfiguration struct {
Retry *RetryConfiguration `yaml:"retry" json:"retry"`
Nodes map[string]*NodeConfiguration `yaml:"nodes" json:"nodes"`
Active string `yaml:"active" json:"active"`
RouteAlgorithm string `yaml:"routeAlgorithm" json:"route-algorithm"`
}
RouterConfiguration yaml router configuration entity
type RouterConfigurationListener ¶
type RouterConfigurationListener interface {
// OnChanged when active data changes will call back
OnChanged(configuration *RouterConfiguration)
}
RouterConfigurationListener remote router configuration listener