Documentation ¶
Index ¶
- Constants
- Variables
- func AdminDir() string
- func AdminPath(name string) string
- func CheckInServerRole(role string) bool
- func CloudPath(product string) string
- func DashCoreBackupPath(product string) string
- func DepartmentPath(product string) string
- func GroupDir(product string) string
- func GroupPath(product string, gid int) string
- func JsonDecode(v interface{}, b []byte) error
- func LockPath(product string) string
- func MigrateDir(product string) string
- func MigratePath(product string, sid int) string
- func PconfigDir(product string) string
- func PconfigPath(product string, name string) string
- func ProductDir(product string) string
- func ProxyDir(product string) string
- func ProxyPath(product string, token string) string
- func SlotPath(product string, sid int) string
- func SqliteInit(db *gorm.DB)
- func ValidateProduct(name string) error
- type Admin
- type AdminRole
- type Client
- type DashCore
- type Department
- type Group
- type GroupServer
- type GroupSlice
- type Migrate
- type MigrateSlice
- type MigrateStatus
- type Pconfig
- type Proxy
- type ProxySlice
- type RedisConnConf
- type Slot
- type SlotMapping
- type Store
- func (s *Store) Acquire(dashCore *DashCore) error
- func (s *Store) AdminDir() string
- func (s *Store) AdminPath(username string) string
- func (s *Store) BackUp(dashCore *DashCore) error
- func (s *Store) BackUpPath() string
- func (s *Store) Client() Client
- func (s *Store) Close() error
- func (s *Store) DeRaftGroup(gid int, addr, token string) error
- func (s *Store) DeleteAdmin(username string) error
- func (s *Store) DeleteGroup(gid int) error
- func (s *Store) DeleteMigrate(sid int) error
- func (s *Store) DeletePconfig(name string) error
- func (s *Store) DeleteProxy(token string) error
- func (s *Store) DepartmentPath() string
- func (s *Store) GroupDir() string
- func (s *Store) GroupPath(gid int) string
- func (s *Store) ListAdmin() (map[string]*Admin, error)
- func (s *Store) ListGroup() (map[int]*Group, error)
- func (s *Store) ListMigrate() (map[int]*Migrate, error)
- func (s *Store) ListPconfig() (map[string]*Pconfig, error)
- func (s *Store) ListProxy() (map[string]*Proxy, error)
- func (s *Store) ListStored() ([]string, error)
- func (s *Store) LoadAdmin(name string) (*Admin, error)
- func (s *Store) LoadBackUpDashCore() (*DashCore, error)
- func (s *Store) LoadDashCore() (*DashCore, error)
- func (s *Store) LoadDepartment() (*Department, error)
- func (s *Store) LoadGroup(gid int) (*Group, error)
- func (s *Store) LoadMigrate(sid int) (*Migrate, error)
- func (s *Store) LoadPconfig(name string) (*Pconfig, error)
- func (s *Store) LoadProxy(token string) (*Proxy, error)
- func (s *Store) LoadSlotMapping(sid int) (*SlotMapping, error)
- func (s *Store) LockPath() string
- func (s *Store) MigrateDir() string
- func (s *Store) MigratePath(sid int) string
- func (s *Store) PconfigDir() string
- func (s *Store) PconfigPath(name string) string
- func (s *Store) ProxyDir() string
- func (s *Store) ProxyPath(token string) string
- func (s *Store) Release() error
- func (s *Store) ReleaseBackUp() error
- func (s *Store) SlotMappings() ([]*SlotMapping, error)
- func (s *Store) SlotPath(sid int) string
- func (s *Store) UpdateAdmin(a *Admin) error
- func (s *Store) UpdateDashCore(t *DashCore) error
- func (s *Store) UpdateDepartment(departmentName, productName string) error
- func (s *Store) UpdateGroup(g *Group) error
- func (s *Store) UpdateMigrate(g *Migrate) error
- func (s *Store) UpdatePconfig(p *Pconfig) error
- func (s *Store) UpdateProxy(p *Proxy) error
- func (s *Store) UpdateSlotMapping(m *SlotMapping) error
- type WhiteAndBlackList
Constants ¶
View Source
const ( ActionNothing = "" ActionPending = "pending" ActionPreparing = "preparing" ActionPrepared = "prepared" ActionMigrating = "migrating" ActionFinished = "finished" ActionSyncing = "syncing" )
View Source
const ( ServerMasterSlaveNode = "master_slave_node" ServerOberserNode = "observer_node" ServerWitnessNode = "witness_node" ServerDeRaftNode = "deraft_single_node" )
View Source
const ( MigratePrepred int = 0 MigrateRunning int = 1 MigrateFinshed int = 2 )
View Source
const ( Local_Cache_Prefix = "Local_Cache_Prefix_PC-" Black_Keys = "Black_Keys" )
View Source
const MaxGroupId = 9999
View Source
const MaxSlotNum = 1024
View Source
const StoredDir = "/stored"
Variables ¶
View Source
var DefaultPconfigKeyList = map[string]*Pconfig{ Local_Cache_Prefix: { Name: Local_Cache_Prefix, Remark: "Black and white list configuration: Proxy local cache", Content: &WhiteAndBlackList{ White: []string{}, Black: []string{}, WhitePrefixes: []string{}, BlackPrefixes: []string{}, WhiteTrie: trie.NewCharTrie([]string{}), BlackTrie: trie.NewCharTrie([]string{}), }, OutOfSync: true, }, Black_Keys: { Name: Black_Keys, Remark: "Black and white list configuration: Block key", Content: &WhiteAndBlackList{ White: []string{}, Black: []string{}, WhitePrefixes: []string{}, BlackPrefixes: []string{}, WhiteTrie: trie.NewCharTrie([]string{}), BlackTrie: trie.NewCharTrie([]string{}), }, OutOfSync: true, }, }
Functions ¶
func CheckInServerRole ¶
func DashCoreBackupPath ¶
func DepartmentPath ¶
func JsonDecode ¶
func MigrateDir ¶
func MigratePath ¶
func PconfigDir ¶
func PconfigPath ¶
func ProductDir ¶
func SqliteInit ¶
func ValidateProduct ¶
Types ¶
type Admin ¶
type Admin struct { Username string `form:"username" binding:"required" json:"username"` Password string `form:"password" binding:"required" json:"password"` Role AdminRole `form:"role" json:"role"` }
func (*Admin) CheckAddRolePower ¶
func (*Admin) CheckOPRolePower ¶
func (*Admin) CheckReadRolePower ¶
type Client ¶
type DashCore ¶
type DashCore struct { Token string `json:"token"` StartTime string `json:"start_time"` AdminAddr string `json:"admin_addr"` HostPort string `json:"hostport"` BackupAddr string `json:"backup_addr"` BackupHostPort string `json:"backup_hostport"` ProductName string `json:"product_name"` ReadCrossCloud bool `json:"read_cross_cloud"` Pid int `json:"pid"` Pwd string `json:"pwd"` Sys string `json:"sys"` }
type Department ¶
type Department struct {
Name string `json:"name"`
}
func LoadDepartment ¶
func LoadDepartment(client Client, product string) (*Department, error)
type Group ¶
type Group struct { Id int `json:"id"` Servers []*GroupServer `json:"servers"` MasterAddr string `json:"master_addr,omitempty"` OutOfSync bool `json:"out_of_sync,omitempty"` IsExpanding bool `json:"is_expanding"` Promoting struct { Index int `json:"index,omitempty"` State string `json:"state,omitempty"` } `json:"promoting"` }
type GroupServer ¶
type GroupServer struct { Addr string `json:"server"` DataCenter string `json:"datacenter"` CloudType string `json:"cloudtype"` ServerRole string `json:"server_role"` ReplicaGroup bool `json:"replica_group"` Action struct { Index int `json:"index,omitempty"` State string `json:"state,omitempty"` } `json:"action"` }
type GroupSlice ¶
type GroupSlice []*Group
func (GroupSlice) Len ¶
func (s GroupSlice) Len() int
func (GroupSlice) Less ¶
func (s GroupSlice) Less(i, j int) bool
func (GroupSlice) Swap ¶
func (s GroupSlice) Swap(i, j int)
type Migrate ¶
type Migrate struct { SID int `json:"sid"` SourceGroupID int `json:"source_group_id"` TargetGroupID int `json:"target_group_id"` Status *MigrateStatus `json:"status"` CreateTime string `json:"create_time"` UpdateTime string `json:"update_time"` }
func SortMigrate ¶
type MigrateSlice ¶
type MigrateSlice []*Migrate
func (MigrateSlice) Len ¶
func (s MigrateSlice) Len() int
func (MigrateSlice) Less ¶
func (s MigrateSlice) Less(i, j int) bool
func (MigrateSlice) Swap ¶
func (s MigrateSlice) Swap(i, j int)
type MigrateStatus ¶
type MigrateStatus struct { Unixtime int64 `json:"unixtime"` Costs int64 `json:"costs"` From string `json:"from"` To string `json:"to"` SlotId int64 `json:"slot_id"` Total int64 `json:"total"` Fails int64 `json:"fails"` SuccPercent string `json:"succ_percent"` Status int `json:"status"` }
func (*MigrateStatus) Encode ¶
func (ms *MigrateStatus) Encode() []byte
type Pconfig ¶
type Pconfig struct { Name string `json:"name"` Remark string `json:"remark"` Content *WhiteAndBlackList `json:"content"` OutOfSync bool `json:"out_of_sync,omitempty"` }
type Proxy ¶
type Proxy struct { Id int `json:"id,omitempty"` Token string `json:"token"` VersionTag string `json:"version_tag"` StartTime string `json:"start_time"` AdminAddr string `json:"admin_addr"` ProtoType string `json:"proto_type"` ProxyAddr string `json:"proxy_addr"` ProductName string `json:"product_name"` CloudType string `json:"cloudtype"` Pid int `json:"pid"` Pwd string `json:"pwd"` Sys string `json:"sys"` Hostname string `json:"hostname"` HostPort string `json:"hostport"` RedisConf *RedisConnConf `json:"redis_conf"` }
type ProxySlice ¶
type ProxySlice []*Proxy
func (ProxySlice) Len ¶
func (s ProxySlice) Len() int
func (ProxySlice) Less ¶
func (s ProxySlice) Less(i, j int) bool
func (ProxySlice) Swap ¶
func (s ProxySlice) Swap(i, j int)
type RedisConnConf ¶
type RedisConnConf struct { HostPort string `toml:"host_port" json:"host_port,omitempty"` MaxIdle int `toml:"max_idle" json:"max_idle"` MaxActive int `toml:"max_active" json:"max_active"` IdleTimeout timesize.Duration `toml:"idle_timeout" json:"idle_timeout"` ConnLifeTime timesize.Duration `toml:"conn_lifetime" json:"conn_lifetime"` Password string `toml:"password" json:"password"` DataBase int `toml:"database" json:"database"` ConnTimeout timesize.Duration `toml:"conn_timeout" json:"conn_timeout"` ReadTimeout timesize.Duration `toml:"read_timeout" json:"read_timeout"` WriteTimeout timesize.Duration `toml:"write_timeout" json:"write_timeout"` }
type Slot ¶
type Slot struct { Id int `json:"id"` Locked bool `json:"locked"` Switched bool `json:"switched"` MasterAddr string `json:"master_addr"` MasterAddrGroupId int `json:"master_addr_group_id"` RoundRobinNum uint64 `json:"round_robin_num"` LocalCloudServers []string `json:"local_servers"` BackupCloudServers []string `json:"backup_servers"` WitnessServers []string `json:"witness_servers"` GroupServersCloudMap map[string]string `json:"group_servers_cloudmap"` GroupServersStats map[string]bool `json:"group_servers_stats"` }
type SlotMapping ¶
type SlotMapping struct { Id int `json:"id"` GroupId int `json:"group_id"` Action struct { NotMigrateData bool `json:"not_migrate_data,omitempty"` Index int `json:"index,omitempty"` State string `json:"state,omitempty"` TargetId int `json:"target_id,omitempty"` } `json:"action"` }
func (*SlotMapping) Encode ¶
func (m *SlotMapping) Encode() []byte
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) BackUpPath ¶
func (*Store) DeleteAdmin ¶
func (*Store) DeleteGroup ¶
func (*Store) DeleteMigrate ¶
func (*Store) DeletePconfig ¶
func (*Store) DeleteProxy ¶
func (*Store) DepartmentPath ¶
func (*Store) ListStored ¶
func (*Store) LoadBackUpDashCore ¶
func (*Store) LoadDashCore ¶
func (*Store) LoadDepartment ¶
func (s *Store) LoadDepartment() (*Department, error)
func (*Store) LoadSlotMapping ¶
func (s *Store) LoadSlotMapping(sid int) (*SlotMapping, error)
func (*Store) MigrateDir ¶
func (*Store) MigratePath ¶
func (*Store) PconfigDir ¶
func (*Store) PconfigPath ¶
func (*Store) ReleaseBackUp ¶
func (*Store) SlotMappings ¶
func (s *Store) SlotMappings() ([]*SlotMapping, error)
func (*Store) UpdateAdmin ¶
func (*Store) UpdateDashCore ¶
func (*Store) UpdateDepartment ¶
func (*Store) UpdateGroup ¶
func (*Store) UpdateMigrate ¶
func (*Store) UpdatePconfig ¶
func (*Store) UpdateProxy ¶
func (*Store) UpdateSlotMapping ¶
func (s *Store) UpdateSlotMapping(m *SlotMapping) error
type WhiteAndBlackList ¶
type WhiteAndBlackList struct { White []string `json:"whitelist"` Black []string `json:"blacklist"` BlackMap map[string]bool `json:"-"` WhiteMap map[string]bool `json:"-"` WhitePrefixes []string `json:"white_prefixes"` BlackPrefixes []string `json:"black_prefixes"` WhiteTrie trie.Trie `json:"-"` BlackTrie trie.Trie `json:"-"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.