Documentation
¶
Index ¶
Constants ¶
View Source
const ( NodeUpStatus = "up" NodeDownStatus = "down" )
View Source
const ( NodeMasterType = "master" NodeSlaveType = "slave" )
View Source
const ( GroupUpStatus = "up" GroupDownStatus = "down" )
View Source
const ( ProxyStatusUp = "up" ProxyStatusDown = "down" )
View Source
const ( RouteTypeHash = "hash" RouteTypeRange = "range" )
Variables ¶
This section is empty.
Functions ¶
func RegisterHashFunc ¶
Types ¶
type Group ¶
Group includes one or more MySQL instances A group must have a master, none or more slaves
type Node ¶
type Node struct { GroupID int `json:"group_id"` Addr string `json:"addr"` Type string `json:"type"` Status string `json:"status"` Weight int `json:"weight"` }
Node is a MySQL instance
type NodeSlice ¶
type NodeSlice []Node
type Proxy ¶
type Proxy struct { // For MySQL protocol communication Addr string `json:"addr"` // Proxy HTTP communication HttpAddr string `json:"http_addr"` Status string `json:"status"` }
Proxy is proxy server
type Route ¶
type Route struct { DB string `json:"db"` Table string `json:"table"` Column string `json:"column"` Type string `json:"type"` // For hash type // crc32, adler32, or you can use your own hash function if registered // default is crc32 Hash string `json:"hash"` // For range type // key format 1-10000, left close and right open // value is sub table id // e.g, if the ranges is {"0-100" : 0, "100-200" : 1} // if a key is 50, we may know that the data will be saved in table_0 Ranges map[string]int `json:"ranges"` }
We will route to let a SQL exexuted in the exact group
type Schema ¶
type Schema struct { Name string `json:"name"` GroupIDs []int `json:"group_ids"` // The default group for the table stored DefaultGroupID int `json:"default_group_id"` // Later use, todo, maybe for migrate Status string `json:"status"` }
Schema is MySQL database, and can be stored in one or more groups.
type Table ¶
type Table struct { DB string `json:"db"` Name string `json:"name"` // If the table is not splitted, it will be stored in this group GroupID int `json:"group_id"` // If the table is splitted, e.g. a user table, may be splitted into 1024, // so the real table may be stored in different groups // like user_0 stored in group_0, user_1 stored in group_1 // the sub table id must start from 0, so we can use a slice to map // the table id -> group id SubTables []int `json:"sub_tables"` // Later use, todo, maybe for migrate Status string `json:"status"` }
Click to show internal directories.
Click to hide internal directories.