Documentation ¶
Index ¶
- Constants
- func IsMycatShardingRule(ruleType string) bool
- func JSONDecode(v interface{}, data []byte) error
- func JSONEncode(v interface{}) []byte
- func ParseDayRange(dateRange string) ([]int, error)
- func ParseMonthRange(dateRange string) ([]int, error)
- func ParseYearRange(dateRange string) ([]int, error)
- type CCConfig
- type Client
- type GlobalSequence
- type Namespace
- type NumKeyRange
- 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(key, 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 ( // MinNumKey min int64 MinNumKey = math.MinInt64 // MaxNumKey max int64 MaxNumKey = math.MaxInt64 )
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" // PartitionLength length of partition PartitionLength = 1024 // mod padding PaddingModLeftEnd = 0 PaddingModRightEnd = 1 PaddingModDefaultPadFrom = PaddingModRightEnd PaddingModDefaultPadLength = 18 PaddingModDefaultModBegin = 10 PaddingModDefaultModEnd = 16 PaddingModDefaultMod = 2 )
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 IsMycatShardingRule ¶ added in v1.0.2
func JSONDecode ¶
JSONDecode parses the JSON-encoded data and stores the result in the value pointed to by v
func ParseDayRange ¶ added in v1.0.2
ParseDayRange return date of daynumber by order 20151201-20151205 20151201,20151202,20151203,20151204,20151205
func ParseMonthRange ¶ added in v1.0.2
ParseMonthRange return date of month by order 201510-201512 201510,201511,201512
func ParseYearRange ¶ added in v1.0.2
ParseYearRange return date of year by order 2013-2015 2013,2014,2015
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"` CoordinatorRoot string `ini:"coordinator_root"` 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"` EncryptKey string `ini:"encrypt_key"` }
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 { IsEncrypt bool `json:"is_encrypt"` // true: 加密存储 false: 非加密存储,目前加密Slice、User中的用户名、密码 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 NumKeyRange ¶ added in v1.0.2
NumKeyRange [start,end)
func ParseNumSharding ¶ added in v1.0.2
func ParseNumSharding(Locations []int, TableRowLimit int) ([]NumKeyRange, error)
ParseNumSharding parse num shard
func (NumKeyRange) Contains ¶ added in v1.0.2
func (kr NumKeyRange) Contains(i int64) bool
Contains check if range contains i
func (NumKeyRange) String ¶ added in v1.0.2
func (kr NumKeyRange) String() string
type Proxy ¶
type Proxy struct { // config type ConfigType string `ini:"config_type"` // 文件配置类型内容 FileConfigPath string `ini:"file_config_path"` // etcd 相关配置 CoordinatorAddr string `ini:"coordinator_addr"` CoordinatorRoot string `ini:"coordinator_root"` 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 EncryptKey string `ini:"encrypt_key"` }
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