Documentation
¶
Index ¶
- Constants
- func JSONDecode(v interface{}, data []byte) error
- func JSONEncode(v interface{}) []byte
- type CCConfig
- type Client
- type GlobalSequence
- type Namespace
- type Proxy
- type ProxyInfo
- type ProxyMonitorMetric
- type Shard
- type Slice
- type Store
- func (s *Store) Close() error
- func (s *Store) CreateProxy(p *ProxyInfo) error
- func (s *Store) DelNamespace(name string) error
- func (s *Store) DeleteProxy(token string) error
- func (s *Store) ListNamespace() ([]string, error)
- func (s *Store) ListProxyMonitorMetrics() (map[string]*ProxyMonitorMetric, error)
- func (s *Store) LoadNamespace(name string) (*Namespace, error)
- func (s *Store) NamespaceBase() string
- func (s *Store) NamespacePath(name string) string
- func (s *Store) ProxyBase() string
- func (s *Store) ProxyPath(token string) string
- func (s *Store) UpdateNamespace(p *Namespace) error
- type User
Constants ¶
const ( ShardDefault = "default" ShardGlobal = "global" ShardLinked = "linked" ShardMod = "mod" ShardHash = "hash" ShardRange = "range" ShardYear = "date_year" ShardMonth = "date_month" ShardDay = "date_day" ShardMycatMod = "mycat_mod" ShardMycatLong = "mycat_long" ShardMycatString = "mycat_string" ShardMycatMURMUR = "mycat_murmur" ShardMycatPaddingMod = "mycat_padding_mod" )
constants of shard type
const ( ConfigFile = "file" ConfigEtcd = "etcd" )
config type
const ( // 只读 ReadOnly = 1 // 可读可写 ReadWrite = 2 )
用户只读标识 read write privileges
const ( // NoReadWriteSplit 非读写分离 NoReadWriteSplit = 0 // ReadWriteSplit 读写分离 ReadWriteSplit = 1 // StatisticUser 统计用户 StatisticUser = 1 )
用户读写分离标识
Variables ¶
This section is empty.
Functions ¶
func JSONDecode ¶
JSONDecode parses the JSON-encoded data and stores the result in the value pointed to by v
Types ¶
type CCConfig ¶
type CCConfig struct {
Addr string `ini:"addr"`
AdminUserName string `ini:"admin_username"`
AdminPassword string `ini:"admin_password"`
ProxyUserName string `ini:"proxy_username"`
ProxyPassword string `ini:"proxy_password"`
// etcd 相关配置
CoordinatorAddr string `ini:"coordinator_addr"`
UserName string `ini:"username"`
Password string `ini:"password"`
LogPath string `ini:"log_path"`
LogLevel string `ini:"log_level"`
LogFileName string `ini:"log_filename"`
LogOutput string `ini:"log_output"`
}
CCConfig means gaea cc config
func ParseCCConfig ¶
ParseCCConfig parser gaea cc config from file
type Client ¶
type Client interface {
Create(path string, data []byte) error
Update(path string, data []byte) error
UpdateWithTTL(path string, data []byte, ttl time.Duration) error
Delete(path string) error
Read(path string) ([]byte, error)
List(path string) ([]string, error)
Close() error
BasePrefix() string
}
Client client interface
type GlobalSequence ¶
type GlobalSequence struct {
DB string `json:"db"`
Table string `json:"table"`
Type string `json:"type"` // 全局序列号类型,目前只兼容mycat的数据库方式
SliceName string `json:"slice_name"` // 对应sequence表所在的分片,默认都在0号片
PKName string `json:"pk_name"` // 全局序列号字段名称
}
GlobalSequence means config of global sequences with different types
func (*GlobalSequence) Encode ¶
func (p *GlobalSequence) Encode() []byte
Encode means encode for easy use
type Namespace ¶
type Namespace struct {
Name string `json:"name"`
Online bool `json:"online"`
ReadOnly bool `json:"read_only"`
AllowedDBS map[string]bool `json:"allowed_dbs"`
DefaultPhyDBS map[string]string `json:"default_phy_dbs"`
SlowSQLTime string `json:"slow_sql_time"`
BlackSQL []string `json:"black_sql"`
AllowedIP []string `json:"allowed_ip"`
Slices []*Slice `json:"slices"`
ShardRules []*Shard `json:"shard_rules"`
Users []*User `json:"users"` // 客户端接入proxy用户,每个用户可以设置读写分离、读写权限等
DefaultSlice string `json:"default_slice"`
GlobalSequences []*GlobalSequence `json:"global_sequences"`
DefaultCharset string `json:"default_charset"`
DefaultCollation string `json:"default_collation"`
}
Namespace means namespace model stored in etcd
type Proxy ¶
type Proxy struct {
// config type
ConfigType string `ini:"config_type"`
// 文件配置类型内容
FileConfigPath string `ini:"file_config_path"`
// etcd 相关配置
CoordinatorAddr string `ini:"coordinator_addr"`
UserName string `ini:"username"`
Password string `ini:"password"`
// 服务相关信息
Environ string `ini:"environ"`
Service string `ini:"service_name"`
LogPath string `ini:"log_path"`
LogLevel string `ini:"log_level"`
LogFileName string `ini:"log_filename"`
LogOutput string `ini:"log_output"`
ProtoType string `ini:"proto_type"`
ProxyAddr string `ini:"proxy_addr"`
AdminAddr string `ini:"admin_addr"`
AdminUser string `ini:"admin_user"`
AdminPassword string `ini:"admin_password"`
SlowSQLTime int64 `ini:"slow_sql_time"`
SessionTimeout int `ini:"session_timeout"`
// 监控配置
StatsEnabled string `ini:"stats_enabled"` // set true to enable stats
}
Proxy means proxy structure of proxy config
func ParseProxyConfigFromFile ¶
ParseProxyConfigFromFile parser proxy config from file
type ProxyInfo ¶
type ProxyInfo struct {
Token string `json:"token"`
StartTime string `json:"start_time"`
IP string `json:"ip"`
ProtoType string `json:"proto_type"`
ProxyPort string `json:"proxy_port"`
AdminPort string `json:"admin_port"`
Pid int `json:"pid"`
Pwd string `json:"pwd"`
Sys string `json:"sys"`
}
ProxyInfo for report proxy information
type ProxyMonitorMetric ¶
type ProxyMonitorMetric struct {
Token string `json:"token"` //目前同AdminAddr
StartTime string `json:"start_time"`
IP string `json:"ip"`
AdminPort string `json:"admin_port"`
ProxyPort string `json:"proxy_port"`
Pid int `json:"pid"`
Pwd string `json:"pwd"`
Sys string `json:"sys"`
}
ProxyMonitorMetric proxy register information
func (*ProxyMonitorMetric) Encode ¶
func (p *ProxyMonitorMetric) Encode() []byte
Encode encode jsosn
type Shard ¶
type Shard struct {
DB string `json:"db"`
Table string `json:"table"`
ParentTable string `json:"parent_table"`
Type string `json:"type"` // 表类型: 包括分表如hash/range/data,关联表如: linked 全局表如: global等
Key string `json:"key"`
Locations []int `json:"locations"`
Slices []string `json:"slices"`
DateRange []string `json:"date_range"`
TableRowLimit int `json:"table_row_limit"`
// only used in mycat logic database (schema)
Databases []string `json:"databases"`
// used in mycat partition long shard and partition string shard
PartitionCount string `json:"partition_count"`
PartitionLength string `json:"partition_length"`
// used in mycat partition string shard
HashSlice string `json:"hash_slice"`
// used in mycat murmur hash shard
Seed string `json:"seed"`
VirtualBucketTimes string `json:"virtual_bucket_times"`
// used in mycat padding mod shard
PadFrom string `json:"pad_from"`
PadLength string `json:"pad_length"`
ModBegin string `json:"mod_begin"`
ModEnd string `json:"mod_end"`
}
Shard means shard model in etcd
type Slice ¶
type Slice struct {
Name string `json:"name"`
UserName string `json:"user_name"`
Password string `json:"password"`
Master string `json:"master"`
Slaves []string `json:"slaves"`
StatisticSlaves []string `json:"statistic_slaves"`
Capacity int `json:"capacity"` // connection pool capacity
MaxCapacity int `json:"max_capacity"` // max connection pool capacity
IdleTimeout int `json:"idle_timeout"` // close backend direct connection after idle_timeout,unit: seconds
}
Slice means config model of slice
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store means exported client to use
func (*Store) CreateProxy ¶
CreateProxy create proxy model
func (*Store) DelNamespace ¶
DelNamespace delete namespace
func (*Store) DeleteProxy ¶
DeleteProxy delete proxy path
func (*Store) ListNamespace ¶
ListNamespace list namespace
func (*Store) ListProxyMonitorMetrics ¶
func (s *Store) ListProxyMonitorMetrics() (map[string]*ProxyMonitorMetric, error)
ListProxyMonitorMetrics list proxies in proxy register path
func (*Store) LoadNamespace ¶
LoadNamespace load namespace value
func (*Store) NamespaceBase ¶
NamespaceBase return namespace path base
func (*Store) NamespacePath ¶
NamespacePath concat namespace path
func (*Store) UpdateNamespace ¶
UpdateNamespace update namespace path with data
type User ¶
type User struct {
UserName string `json:"user_name"`
Password string `json:"password"`
Namespace string `json:"namespace"`
RWFlag int `json:"rw_flag"` //1: 只读 2:读写
RWSplit int `json:"rw_split"` //0: 不采用读写分离 1:读写分离
OtherProperty int `json:"other_property"` // 1:统计用户
}
User meand user struct