Documentation
¶
Index ¶
- Variables
- 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(name string, options map[string]interface{}) error
- func Register(s StoreOperate)
- func Validate(cfg *Configuration) error
- type Center
- func (c *Center) Close() error
- func (c *Center) ImportConfiguration(cfg *Configuration) error
- func (c *Center) Load() (*Configuration, error)
- func (c *Center) LoadContext(ctx context.Context) (*Configuration, error)
- func (c *Center) Persist() error
- func (c *Center) PersistContext(ctx context.Context) error
- type Changeable
- type ConfigOptions
- type Configuration
- type Data
- type DataSourceCluster
- type DataSourceType
- type Decoder
- type Group
- type Listener
- type MatchRule
- type Node
- type Observer
- type ParametersMap
- type PathKey
- type Prop
- type ProtocolType
- type Rule
- type RuleAttribute
- type Sequence
- type ShadowRule
- type ShadowTable
- type ShardingRule
- type SocketAddress
- type StoreOperate
- type Table
- type Tenant
- type Topology
- type User
Constants ¶
This section is empty.
Variables ¶
var (
ConfigKeyMapping map[PathKey]string = map[PathKey]string{
DefaultConfigMetadataPath: "metadata",
DefaultConfigDataTenantsPath: "data.tenants",
DefaultConfigDataListenersPath: "data.listeners",
DefaultConfigDataSourceClustersPath: "data.clusters",
DefaultConfigDataShardingRulePath: "data.sharding_rule",
}
)
Functions ¶
func GetConnPropCapacity ¶
GetConnPropCapacity parses the capacity of backend connection pool, return default value if failed.
func GetConnPropIdleTime ¶
func GetConnPropIdleTime(connProps map[string]interface{}, defaultValue time.Duration) time.Duration
GetConnPropIdleTime parses the idle time of backend connection pool, return default value if failed.
func GetConnPropMaxCapacity ¶
GetConnPropMaxCapacity parses the max capacity of backend connection pool, return default value if failed.
Types ¶
type Center ¶
type Center struct {
// contains filtered or unexported fields
}
func NewCenter ¶
func NewCenter(options ConfigOptions) (*Center, error)
func (*Center) ImportConfiguration ¶
func (c *Center) ImportConfiguration(cfg *Configuration) error
func (*Center) Load ¶
func (c *Center) Load() (*Configuration, error)
func (*Center) LoadContext ¶
func (c *Center) LoadContext(ctx context.Context) (*Configuration, error)
type Changeable ¶
type ConfigOptions ¶
type Configuration ¶
type Configuration struct { Kind string `yaml:"kind" json:"kind,omitempty"` APIVersion string `yaml:"apiVersion" json:"apiVersion,omitempty"` Metadata map[string]interface{} `yaml:"metadata" json:"metadata"` Data *Data `validate:"required,structonly" yaml:"data" json:"data"` }
Configuration represents an Arana configuration.
func Load ¶
func Load(path string) (*Configuration, error)
Load loads the configuration from file path.
type Data ¶
type Data struct { Listeners []*Listener `validate:"required,dive" yaml:"listeners" json:"listeners"` Tenants []*Tenant `validate:"required,dive" yaml:"tenants" json:"tenants"` DataSourceClusters []*DataSourceCluster `validate:"required,dive" yaml:"clusters" json:"clusters"` ShardingRule *ShardingRule `validate:"required,dive" yaml:"sharding_rule,omitempty" json:"sharding_rule,omitempty"` ShadowRule *ShadowRule `yaml:"shadow_rule,omitempty" json:"shadow_rule,omitempty"` }
type DataSourceCluster ¶
type DataSourceCluster struct { Name string `yaml:"name" json:"name"` Type DataSourceType `yaml:"type" json:"type"` SqlMaxLimit int `default:"-1" yaml:"sql_max_limit" json:"sql_max_limit,omitempty"` Tenant string `yaml:"tenant" json:"tenant"` Parameters ParametersMap `yaml:"parameters" json:"parameters"` Groups []*Group `yaml:"groups" json:"groups"` }
type DataSourceType ¶
type DataSourceType string
DataSourceType is the data source type
const ( DBMySQL DataSourceType = "mysql" DBPostgreSQL DataSourceType = "postgresql" )
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder decodes configuration.
func NewDecoder ¶
NewDecoder creates a Decoder from a reader.
type Listener ¶
type Listener struct { ProtocolType string `yaml:"protocol_type" json:"protocol_type"` SocketAddress *SocketAddress `yaml:"socket_address" json:"socket_address"` ServerVersion string `yaml:"server_version" json:"server_version"` }
type MatchRule ¶
type MatchRule struct { Operation []string `yaml:"operation" json:"operation"` MatchType string `yaml:"match_type" json:"match_type"` Attributes []*RuleAttribute `yaml:"attributes" json:"attributes"` }
type Node ¶
type Node struct { Name string `validate:"required" yaml:"name" json:"name"` Host string `validate:"required" yaml:"host" json:"host"` Port int `validate:"required" yaml:"port" json:"port"` Username string `validate:"required" yaml:"username" json:"username"` Password string `validate:"required" yaml:"password" json:"password"` Database string `validate:"required" yaml:"database" json:"database"` Parameters ParametersMap `yaml:"parameters" json:"parameters"` ConnProps map[string]interface{} `yaml:"conn_props" json:"conn_props,omitempty"` Weight string `default:"r10w10" yaml:"weight" json:"weight"` Labels map[string]string `yaml:"labels" json:"labels,omitempty"` }
type ParametersMap ¶
func (*ParametersMap) Camel ¶
func (pm *ParametersMap) Camel(name string) string
Camel underline to camel
func (*ParametersMap) LowerCaseFirstLetter ¶
func (pm *ParametersMap) LowerCaseFirstLetter(str string) string
LowerCaseFirstLetter lowercase letter
func (*ParametersMap) Merge ¶
func (pm *ParametersMap) Merge(parametersMap ParametersMap)
func (*ParametersMap) String ¶
func (pm *ParametersMap) String() string
type PathKey ¶
type PathKey string
PathKey config path key type
const ( DefaultConfigPath PathKey = "/arana-db/config" DefaultConfigMetadataPath PathKey = "/arana-db/config/metadata" DefaultConfigDataListenersPath PathKey = "/arana-db/config/data/listeners" DefaultConfigDataSourceClustersPath PathKey = "/arana-db/config/data/dataSourceClusters" DefaultConfigDataShardingRulePath PathKey = "/arana-db/config/data/shardingRule" DefaultConfigDataTenantsPath PathKey = "/arana-db/config/data/tenants" )
type ProtocolType ¶
type ProtocolType int32
ProtocolType protocol type enum
const ( Http ProtocolType = iota MySQL )
func (*ProtocolType) UnmarshalText ¶
func (t *ProtocolType) UnmarshalText(text []byte) error
type RuleAttribute ¶
type ShadowRule ¶
type ShadowRule struct {
ShadowTables []*ShadowTable `yaml:"tables" json:"tables"`
}
type ShadowTable ¶
type ShardingRule ¶
type ShardingRule struct {
Tables []*Table `yaml:"tables" json:"tables"`
}
type SocketAddress ¶
type SocketAddress struct { Address string `default:"0.0.0.0" yaml:"address" json:"address"` Port int `default:"13306" yaml:"port" json:"port"` }
SocketAddress specify either a logical or physical address and port, which are used to tell server where to bind/listen, connect to upstream and find management servers
type StoreOperate ¶
type StoreOperate interface { io.Closer // Init plugin initialization Init(options map[string]interface{}) error // Save save a configuration data Save(key PathKey, val []byte) error // Get get a configuration Get(key PathKey) ([]byte, error) // Watch Monitor changes of the key Watch(key PathKey) (<-chan []byte, error) // Name plugin name Name() string }
StoreOperate config storage related plugins
func GetStoreOperate ¶
func GetStoreOperate() (StoreOperate, error)
type Table ¶
type Table struct { Name string `validate:"required" yaml:"name" json:"name"` Sequence *Sequence `yaml:"sequence" json:"sequence"` AllowFullScan bool `yaml:"allow_full_scan" json:"allow_full_scan,omitempty"` DbRules []*Rule `yaml:"db_rules" json:"db_rules"` TblRules []*Rule `yaml:"tbl_rules" json:"tbl_rules"` Topology *Topology `yaml:"topology" json:"topology"` ShadowTopology *Topology `yaml:"shadow_topology" json:"shadow_topology"` Attributes map[string]string `yaml:"attributes" json:"attributes"` }