config

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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"`
}

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

GetDataSource Get datasource configuration map through merge local cluster configuration and remote cluster configuration.

func (*IntegrationClusterConfiguration) GetRouterConfig

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

type RetryConfiguration struct {
	Times string `yaml:"times"`
	Delay string `yaml:"delay"`
}

RetryConfiguration yaml retry configuration entity

type RouterConfiguration

type RouterConfiguration struct {
	Retry          *RetryConfiguration           `yaml:"retry"`
	Nodes          map[string]*NodeConfiguration `yaml:"nodes"`
	Active         string                        `yaml:"active"`
	RouteAlgorithm string                        `yaml:"routeAlgorithm"`
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL