Documentation ¶
Index ¶
- Constants
- Variables
- func ActionGC(zkConn zkhelper.Conn, productName string, gcType int, keep int) error
- func CreateActionRootPath(zkConn zkhelper.Conn, path string) error
- func CreateProxyFenceNode(zkConn zkhelper.Conn, productName string, pi *ProxyInfo) (string, error)
- func CreateProxyInfo(zkConn zkhelper.Conn, productName string, pi *ProxyInfo) (string, error)
- func ExtraSeqList(nodes []string) ([]int, error)
- func ForceRemoveDeadFence(zkConn zkhelper.Conn, productName string) error
- func ForceRemoveLock(zkConn zkhelper.Conn, productName string) error
- func GetActionObject(zkConn zkhelper.Conn, productName string, seq int64, act interface{}, ...) error
- func GetActionResponsePath(productName string) string
- func GetActionSeqList(zkConn zkhelper.Conn, productName string) ([]int, error)
- func GetFenceProxyMap(zkConn zkhelper.Conn, productName string) (map[string]bool, error)
- func GetProxyFencePath(productName string) string
- func GetProxyPath(productName string) string
- func GetSlotBasePath(productName string) string
- func GetSlotPath(productName string, slotId int) string
- func GetWatchActionPath(productName string) string
- func GroupExists(zkConn zkhelper.Conn, productName string, groupId int) (bool, error)
- func InitSlotSet(zkConn zkhelper.Conn, productName string, totalSlotNum int) error
- func NewAction(zkConn zkhelper.Conn, productName string, actionType ActionType, ...) error
- func NewActionWithTimeout(zkConn zkhelper.Conn, productName string, actionType ActionType, ...) error
- func SetProxyStatus(zkConn zkhelper.Conn, productName string, proxyName string, status string) error
- func SetSlotRange(zkConn zkhelper.Conn, productName string, fromSlot, toSlot, groupId int, ...) error
- func WaitForReceiverWithTimeout(zkConn zkhelper.Conn, productName string, actionZkPath string, ...) error
- type Action
- type ActionType
- type ProxyInfo
- type Server
- type ServerGroup
- func (self *ServerGroup) AddServer(zkConn zkhelper.Conn, s *Server, passwd string) error
- func (self *ServerGroup) Create(zkConn zkhelper.Conn) error
- func (self *ServerGroup) Exists(zkConn zkhelper.Conn) (bool, error)
- func (self *ServerGroup) GetServers(zkConn zkhelper.Conn) ([]*Server, error)
- func (self *ServerGroup) Master(zkConn zkhelper.Conn) (*Server, error)
- func (self *ServerGroup) Promote(conn zkhelper.Conn, addr, passwd string) error
- func (self *ServerGroup) Remove(zkConn zkhelper.Conn) error
- func (self *ServerGroup) RemoveServer(zkConn zkhelper.Conn, addr string) error
- func (self *ServerGroup) String() string
- type Slot
- type SlotMigrateStatus
- type SlotMultiSetParam
- type SlotState
- type SlotStatus
Constants ¶
View Source
const ( GC_TYPE_N = iota + 1 GC_TYPE_SEC )
View Source
const ( PROXY_STATE_ONLINE = "online" PROXY_STATE_OFFLINE = "offline" PROXY_STATE_MARK_OFFLINE = "mark_offline" )
View Source
const ( SERVER_TYPE_MASTER string = "master" SERVER_TYPE_SLAVE string = "slave" SERVER_TYPE_OFFLINE string = "offline" )
View Source
const (
DEFAULT_SLOT_NUM = 1024
)
View Source
const (
INVALID_ID = -1
)
Variables ¶
View Source
var ErrNodeExists = errors.New("node already exists")
View Source
var ErrReceiverTimeout = errors.New("receiver timeout")
View Source
var ErrSlotAlreadyExists = errors.New("slots already exists")
View Source
var ErrUnknownProxyStatus = errors.New("unknown status, should be (online offline)")
View Source
var ErrUnknownSlotStatus = errors.New("unknown slot status, slot status should be (online, offline, migrate, pre_migrate)")
Functions ¶
func CreateProxyFenceNode ¶
func CreateProxyInfo ¶
func ExtraSeqList ¶
func ForceRemoveDeadFence ¶
func GetActionObject ¶
func GetActionResponsePath ¶
func GetActionSeqList ¶
func GetFenceProxyMap ¶
func GetProxyFencePath ¶
func GetProxyPath ¶
func GetSlotBasePath ¶
func GetSlotPath ¶
func GetWatchActionPath ¶
func GroupExists ¶
func InitSlotSet ¶
danger operation !
func NewActionWithTimeout ¶
func SetProxyStatus ¶
func SetSlotRange ¶
Types ¶
type Action ¶
type Action struct { Type ActionType `json:"type"` Desc string `json:"desc"` Target interface{} `json:"target"` Ts string `json:"ts"` // timestamp Receivers []string `json:"receivers"` }
type ActionType ¶
type ActionType string
const ( ACTION_TYPE_SERVER_GROUP_CHANGED ActionType = "group_changed" ACTION_TYPE_SERVER_GROUP_REMOVE ActionType = "group_remove" ACTION_TYPE_SLOT_CHANGED ActionType = "slot_changed" ACTION_TYPE_MULTI_SLOT_CHANGED ActionType = "multi_slot_changed" ACTION_TYPE_SLOT_MIGRATE ActionType = "slot_migrate" ACTION_TYPE_SLOT_PREMIGRATE ActionType = "slot_premigrate" )
type ProxyInfo ¶
type ProxyInfo struct { Id string `json:"id"` Addr string `json:"addr"` LastEvent string `json:"last_event"` LastEventTs int64 `json:"last_event_ts"` State string `json:"state"` Description string `json:"description"` DebugVarAddr string `json:"debug_var_addr"` Pid int `json:"pid"` StartAt string `json:"start_at"` }
func GetProxyInfo ¶
type Server ¶
type Server struct { Type string `json:"type"` GroupId int `json:"group_id"` Addr string `json:"addr"` }
redis server instance
type ServerGroup ¶
type ServerGroup struct { Id int `json:"id"` ProductName string `json:"product_name"` Servers []*Server `json:"servers"` }
redis server group
func NewServerGroup ¶
func NewServerGroup(productName string, id int) *ServerGroup
func ServerGroups ¶
func ServerGroups(zkConn zkhelper.Conn, productName string) ([]*ServerGroup, error)
func (*ServerGroup) GetServers ¶
func (self *ServerGroup) GetServers(zkConn zkhelper.Conn) ([]*Server, error)
func (*ServerGroup) Promote ¶
func (self *ServerGroup) Promote(conn zkhelper.Conn, addr, passwd string) error
func (*ServerGroup) RemoveServer ¶
func (self *ServerGroup) RemoveServer(zkConn zkhelper.Conn, addr string) error
func (*ServerGroup) String ¶
func (self *ServerGroup) String() string
type Slot ¶
type Slot struct { ProductName string `json:"product_name"` Id int `json:"id"` GroupId int `json:"group_id"` State SlotState `json:"state"` }
func GetMigratingSlots ¶
func (*Slot) SetMigrateStatus ¶
type SlotMigrateStatus ¶
type SlotMultiSetParam ¶
type SlotMultiSetParam struct { From int `json:"from"` To int `json:"to"` Status SlotStatus `json:"status"` GroupId int `json:"group_id"` }
type SlotState ¶
type SlotState struct { Status SlotStatus `json:"status"` MigrateStatus SlotMigrateStatus `json:"migrate_status"` LastOpTs string `json:"last_op_ts"` // operation timestamp }
type SlotStatus ¶
type SlotStatus string
const ( SLOT_STATUS_ONLINE SlotStatus = "online" SLOT_STATUS_OFFLINE SlotStatus = "offline" SLOT_STATUS_MIGRATE SlotStatus = "migrate" SLOT_STATUS_PRE_MIGRATE SlotStatus = "pre_migrate" )
Click to show internal directories.
Click to hide internal directories.