Documentation ¶
Index ¶
- Constants
- type Backend
- type Database
- type Election
- type Info
- func (m *Info) AddBDatabase(db *Database) error
- func (m *Info) AddUser(user, password string) error
- func (m *Info) CheckUser(user string, auth []byte, salt []byte, db string) bool
- func (m *Info) CheckUserDirect(user, password string) bool
- func (m *Info) CreateAndHeartBeat(key, value string, ttl uint64, isThrow bool) (stop func(), err error)
- func (m *Info) GetAllProxyNodes() ([]string, error)
- func (m *Info) GetAutoKey(user, db, table, key string, interval uint64) (uint64, error)
- func (m *Info) GetDBs(user, db string) ([]*Backend, error)
- func (d *Info) GetMaster(user string) (master string, err error)
- func (m *Info) GetMysqlNodes() ([]*MysqlNode, error)
- func (m *Info) GetTable(user, db, table string) (*Table, error)
- func (d *Info) GetTaskStatus(user, id string) ([]byte, error)
- func (d *Info) GetTasks(user string) (etcd.Nodes, error)
- func (m *Info) GetUserInfo(user string) (*etcd.Response, error)
- func (m *Info) IsDBExist(user, db string) (bool, error)
- func (m *Info) IsTableExist(user, db, table string) (bool, error)
- func (d *Info) Lock(key string, id string, seq int64) error
- func (d *Info) SaveCreateDatabase(user, db, tid string, backends []*Backend) error
- func (d *Info) SaveCreateTable(user, db, tid string, table *Table) error
- func (d *Info) SaveDDLTask(v interface{}, user string) (string, error)
- func (d *Info) SetTaskStatus(user, id string, data []byte) error
- func (m *Info) ShowDatabases(user string) ([]string, error)
- func (m *Info) ShowTables(user, db string) ([]string, error)
- func (d *Info) UnLock(key string, id string, seq int64) error
- func (d *Info) UpdateTask(user, id, value string) error
- type Key
- type MysqlNode
- type SortBackends
- type Table
Constants ¶
const ( Perfix = "/rambo" ProxyNodes = Perfix + "/proxy_nodes" UserInfo = Perfix + "/user_info" Password = "/password" DB = "/db" Backends = "/backends" // DB's sub dir. // Scheme = "/scheme" // DB's sub dir. Config = "/config" // DB's sub dir. Tables = "/tables" // DB's sub dir. // MysqlInfo is Mysql backends' config. // MysqlInfo is a dir. // each backend node's config record in a name which named // by the backend's name. MysqlInfo = Perfix + "/mysql_info" Hash = "hash" Range = "range" CHash = "chash" DDLInfo = Perfix + "/ddl_info" TaskStatus = "task_status" // DDLInfo/[user]/TaskStatus/[task_id] Masters = "/masters" // k: user id, v: node addr TaskQueue = "/task_queue" // k: user id, v: ddl excute plan Lock = "/lock" // k: user/db/table, v: "lock" AutoKey = Perfix + "/auto_key" )
const ( NotFound = 100 NotEqual = 101 AlreadyExist = 105 )
etcd error code
const ( Delete = "delete" Set = "set" Create = "create" Update = "update" Expire = "expire" Get = "get" CAS = "compareAndSwap" CAD = "compareAndDelete" )
etcd action
const ( TypeKeyInt = iota TypeKeyString TypeKeyUnknow )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct { Seq int `json:"seq"` Host string `json:"host"` UserName string `json:"user-name"` Password string `json:"password"` Name string `json:"name"` // backend's name ParentNode *MysqlNode `json:"parent"` }
Backend is one of user's backends
type Election ¶
type Election struct {
// contains filtered or unexported fields
}
Election is elect leader in etcd
func NewElection ¶
type Info ¶
Info is metaDB's global public instance.
func (*Info) AddBDatabase ¶
func (*Info) CheckUserDirect ¶
func (*Info) CreateAndHeartBeat ¶
func (m *Info) CreateAndHeartBeat(key, value string, ttl uint64, isThrow bool) (stop func(), err error)
CreateAndHeartBeat create a k/v in etcd. And half a ttl, is will refresh the kv's ttl. If fail, will return an error. If error is nil it will return a named Stop function, it will stop the update tick.
func (*Info) GetAllProxyNodes ¶
GetAllProxyNodes will get all proxy nodes
func (*Info) GetAutoKey ¶
func (*Info) GetMysqlNodes ¶
GetMysqlNodes get all mysql backend nodes
func (*Info) GetTaskStatus ¶
GetTaskStatus get task's status
func (*Info) SaveCreateDatabase ¶
SaveCreateDatabase save db info into etcd
func (*Info) SaveCreateTable ¶
SaveCreateTable save table info into etcd
func (*Info) SaveDDLTask ¶
SaveDDLTask save ddl task, return the task id
func (*Info) SetTaskStatus ¶
SetTaskStatus set task's status
func (*Info) UpdateTask ¶
UpdateTask will update this task
type MysqlNode ¶
type MysqlNode struct { Host string `json:"host"` UserName string `json:"user-name"` Password string `json:"password"` Name string `json:"name"` // node's name }
MysqlNode is one mysql server.
type SortBackends ¶
type SortBackends []*Backend
func (SortBackends) Len ¶
func (s SortBackends) Len() int
func (SortBackends) Less ¶
func (s SortBackends) Less(i, j int) bool
func (SortBackends) Swap ¶
func (s SortBackends) Swap(i, j int)