Versions in this module Expand all Collapse all v0 v0.2.0 Sep 30, 2023 Changes in this version + const ConfigItemClusters + const ConfigItemNodes + const ConfigItemShadowRule + const ConfigItemShardingRule + const ConfigItemSpec + const ConfigItemSysDB + const ConfigItemUsers + var ErrorNoStoreOperate = errors.New("no store operate") + var ErrorNotImplement = errors.New("not implement") + func GetConnPropCapacity(connProps map[string]interface{}, defaultValue int) int + func GetConnPropIdleTime(connProps map[string]interface{}, defaultValue time.Duration) time.Duration + func GetConnPropMaxCapacity(connProps map[string]interface{}, defaultValue int) int + func Init(options Options, version string) error + func InitStoreOperate(options Options) error + func JSONToYAML(j string) ([]byte, error) + func NewConfigWatcher(tenant string, storeOperate StoreOperator, pathInfo *PathInfo) (*configWatcher, error) + func Register(s StoreOperator) error + func Validate(cfg *Configuration) error + func WithCacheable(open bool) option + func WithReader(open bool) option + func WithWatcher(open bool) option + func WithWriter(open bool) option + type BootOptions struct + Config *Options + Listeners []*Listener + Logging *log.Config + Registry *Registry + Supervisor *User + Trace *Trace + func LoadBootOptions(path string) (*BootOptions, error) + type CacheConfigReaderTest = cacheConfigReader + type Center interface + Tenant func() string + func NewCenter(tenant string, storeOperate StoreOperator, opts ...option) (Center, error) + type CenterTest = center + type ClusterEvent struct + GroupsEvent *GroupsEvent + Name string + Parameters ParametersMap + SqlMaxLimit int + Type DataSourceType + type Clusters []*DataSourceCluster + func (c Clusters) Diff(old Clusters) *ClustersEvent + type ClustersEvent struct + AddClusters Clusters + DeleteClusters Clusters + UpdateClusters []*ClusterEvent + func (e ClustersEvent) Type() EventType + type ColumnRule struct + Name string + Step int + Type string + type ConfigItem string + type ConfigReader interface + Load func(ctx context.Context, item ConfigItem) (*Tenant, error) + LoadAll func(ctx context.Context) (*Tenant, error) + type ConfigWatcher interface + Subscribe func(ctx context.Context, et EventType, c EventCallback) (context.CancelFunc, error) + type ConfigWatcherTest configWatcher + type ConfigWriter interface + Import func(ctx context.Context, cfg *Tenant) error + Write func(ctx context.Context, item ConfigItem, cfg *Tenant) error + type Configuration struct + Data *Data + func Load(path string) (*Configuration, error) + type Data struct + Tenants []*Tenant + type DataRevision interface + Revision func() string + type DataSourceCluster struct + Groups []*Group + Name string + Parameters ParametersMap + SqlMaxLimit int + Type DataSourceType + func (d *DataSourceCluster) Diff(old *DataSourceCluster) *ClusterEvent + type DataSourceType string + const DBMySQL + const DBPostgreSQL + type Decoder struct + func NewDecoder(reader io.Reader) *Decoder + func (d *Decoder) Decode(v interface{}) error + type Event interface + Type func() EventType + type EventCallback func(e Event) + type EventType int32 + const EventTypeClusters + const EventTypeNodes + const EventTypeShadowRule + const EventTypeShardingRule + const EventTypeTenants + const EventTypeUsers + type Group struct + Name string + Nodes []string + type GroupEvent struct + AddNodes Nodes + DeleteNodes Nodes + Name string + UpdateNodes Nodes + type Groups []*Group + func (g Groups) Diff(old Groups) *GroupsEvent + type GroupsEvent struct + AddGroups Groups + DeleteGroups Groups + UpdateGroups Groups + type Listener struct + ProtocolType string + ServerVersion string + SocketAddress *SocketAddress + func (l *Listener) String() string + type MatchRule struct + Attributes []*RuleAttribute + MatchType string + Operation []string + type Node struct + ConnProps map[string]interface{} + Database string + Host string + Labels map[string]string + Name string + Parameters ParametersMap + Password string + Port int + Username string + Weight string + func (nd *Node) Equals(o *Node) bool + func (nd *Node) GetReadAndWriteWeight() (int, int, error) + func (nd *Node) String() string + type Nodes map[string]*Node + func (n Nodes) Diff(old Nodes) *NodesEvent + type NodesEvent struct + AddNodes []*Node + DeleteNodes []*Node + UpdateNodes []*Node + func (e NodesEvent) Type() EventType + type Options struct + Options map[string]interface{} + RootPath string + StoreName string + type ParametersMap map[string]string + func (pm *ParametersMap) Camel(name string) string + func (pm *ParametersMap) LowerCaseFirstLetter(str string) string + func (pm *ParametersMap) Merge(parametersMap ParametersMap) + func (pm *ParametersMap) String() string + type PathInfo struct + BuildEventMapping map[EventType]func(pre, cur *Tenant) Event + ConfigEventMapping map[PathKey]EventType + ConfigKeyMapping map[PathKey]string + ConfigValSupplier map[PathKey]func(cfg *Tenant) interface{} + DefaultConfigDataNodesPath PathKey + DefaultConfigDataShadowRulePath PathKey + DefaultConfigDataShardingRulePath PathKey + DefaultConfigDataSourceClustersPath PathKey + DefaultConfigDataUsersPath PathKey + DefaultConfigSpecPath PathKey + DefaultConfigSysDBPath PathKey + DefaultTenantBaseConfigPath PathKey + func NewPathInfo(tenant string) *PathInfo + type PathKey string + var DefaultRootPath PathKey + var DefaultTenantsPath PathKey + type Prop struct + Column string + Operation string + Regex string + Value string + type ProtocolType int32 + const Http + const MySQL + func (t *ProtocolType) UnmarshalText(text []byte) error + type Registry struct + Enable bool + Name string + Options map[string]interface{} + RootPath string + type Rule struct + Columns []*ColumnRule + Expr string + Type string + type RuleAttribute struct + Column string + Regex string + Value string + type Rules []*Rule + func (r Rules) Equals(o Rules) bool + type Sequence struct + Option map[string]string + Type string + type ShadowRule struct + ShadowTables []*ShadowTable + func (s *ShadowRule) Diff(old *ShadowRule) *ShadowRuleEvent + type ShadowRuleEvent struct + AddTables []*ShadowTable + DeleteTables []*ShadowTable + UpdateTables []*ShadowTable + func (e ShadowRuleEvent) Type() EventType + type ShadowTable struct + Enable bool + GroupNode string + MatchRules []*MatchRule + Name string + type ShardingRule struct + Tables []*Table + func (s *ShardingRule) Diff(old *ShardingRule) *ShardingRuleEvent + type ShardingRuleEvent struct + AddTables []*Table + DeleteTables []*Table + UpdateTables []*Table + func (e ShardingRuleEvent) Type() EventType + type SocketAddress struct + Address string + Port int + type Spec struct + APIVersion string + EnableLocalMathComputation bool + Kind string + LogPath string + Metadata map[string]interface{} + SlowLogPath string + type StoreOperator interface + Get func(key PathKey) ([]byte, error) + Init func(options map[string]interface{}) error + Name func() string + Save func(key PathKey, val []byte) error + Watch func(key PathKey) (<-chan []byte, error) + func GetStoreOperate() StoreOperator + type SubscribeResult struct + Cancel context.CancelFunc + EventChan <-chan Event + type Table struct + Attributes map[string]string + DbRules []*Rule + Name string + Sequence *Sequence + ShadowTopology *Topology + TblRules []*Rule + Topology *Topology + func (t *Table) Equals(o *Table) bool + type Tenant struct + DataSourceClusters []*DataSourceCluster + Name string + Nodes map[string]*Node + ShadowRule *ShadowRule + ShardingRule *ShardingRule + SysDB *Node + Users []*User + func NewEmptyTenant() *Tenant + func (t *Tenant) Empty() bool + type TenantOperator interface + CreateTenant func(string) error + CreateTenantUser func(tenant, username, password string) error + ListTenants func() []string + RemoveNode func(tenant, name string) error + RemoveTenant func(string) error + RemoveTenantUser func(tenant, username string) error + Subscribe func(ctx context.Context, c EventCallback) context.CancelFunc + UpdateTenant func(tenant string, newTenant string) error + UpdateTenantUser func(tenant, newUsername, password, oldUsername string) error + UpsertNode func(tenant, node, name, host string, port int, ...) error + func LoadTenantOperator(cfg *BootOptions) (TenantOperator, error) + func LoadTenantOperatorFromPath(path string) (TenantOperator, error) + func NewTenantOperator(op StoreOperator) (TenantOperator, error) + type Tenants []string + func (t Tenants) Diff(old Tenants) *TenantsEvent + type TenantsEvent struct + AddTenants Tenants + DeleteTenants Tenants + func (e TenantsEvent) Type() EventType + type Topology struct + DbPattern string + TblPattern string + type Trace struct + Address string + Type string + type User struct + Password string + Username string + func (u *User) Equals(o *User) bool + type Users []*User + func (u Users) Diff(old Users) *UsersEvent + type UsersEvent struct + AddUsers Users + DeleteUsers Users + UpdateUsers Users + func (e UsersEvent) Type() EventType v0.1.0-rc1 Sep 1, 2022