Documentation ¶
Index ¶
- Constants
- Variables
- func ActionGC(coordConn zkhelper.Conn, productName string, gcType int, keep int) error
- func CreateActionRootPath(coordConn zkhelper.Conn, path string) error
- func CreateProxyFenceNode(coordConn zkhelper.Conn, productName string, pi *ProxyInfo) (string, error)
- func CreateProxyInfo(coordConn zkhelper.Conn, productName string, pi *ProxyInfo) (string, error)
- func ExtraSeqList(nodes []string) ([]int, error)
- func ForceRemoveDeadFence(coordConn zkhelper.Conn, productName string) error
- func ForceRemoveLock(coordConn zkhelper.Conn, productName string) error
- func GetActionObject(coordConn zkhelper.Conn, productName string, seq int64, act interface{}, ...) error
- func GetActionResponsePath(productName string) string
- func GetActionSeqList(coordConn zkhelper.Conn, productName string) ([]int, error)
- func GetFenceProxyMap(coordConn 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(coordConn zkhelper.Conn, productName string, groupId int) (bool, error)
- func InitSlotSet(coordConn zkhelper.Conn, productName string, totalSlotNum int) error
- func NewAction(coordConn zkhelper.Conn, productName string, actionType ActionType, ...) error
- func NewActionWithTimeout(coordConn zkhelper.Conn, productName string, actionType ActionType, ...) error
- func SetProxyStatus(coordConn zkhelper.Conn, productName string, proxyName string, status string) error
- func SetSlotRange(coordConn zkhelper.Conn, productName string, fromSlot, toSlot, groupId int, ...) error
- func SetSlots(coordConn zkhelper.Conn, productName string, slots []*Slot, groupId int, ...) error
- func WaitForReceiverWithTimeout(coordConn zkhelper.Conn, productName string, actionCoordPath string, ...) error
- type Action
- type ActionType
- type ProxyInfo
- type Server
- type ServerGroup
- func (sg *ServerGroup) AddServer(coordConn zkhelper.Conn, s *Server, auth string) error
- func (sg *ServerGroup) Create(coordConn zkhelper.Conn) error
- func (sg *ServerGroup) Exists(coordConn zkhelper.Conn) (bool, error)
- func (sg *ServerGroup) GetServers(coordConn zkhelper.Conn) ([]*Server, error)
- func (sg *ServerGroup) Master(coordConn zkhelper.Conn) (*Server, error)
- func (sg *ServerGroup) Promote(conn zkhelper.Conn, addr string, auth string) error
- func (sg *ServerGroup) Remove(coordConn zkhelper.Conn) error
- func (sg *ServerGroup) RemoveServer(coordConn zkhelper.Conn, addr string) error
- func (sg *ServerGroup) String() string
- type Slot
- func GetMigratingSlots(conn zkhelper.Conn, productName string) ([]*Slot, error)
- func GetSlot(coordConn zkhelper.Conn, productName string, id int) (*Slot, error)
- func NewSlot(productName string, id int) *Slot
- func NoGroupSlots(coordConn zkhelper.Conn, productName string) ([]*Slot, error)
- func Slots(coordConn zkhelper.Conn, productName string) ([]*Slot, error)
- 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"` }
func GetActionWithSeq ¶
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" ActionTimeoutMs = 30 * 1000 CheckTimeIntervalMs = 500 MaxKeepActionsNum = 500 )
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(coordConn zkhelper.Conn, productName string) ([]*ServerGroup, error)
func (*ServerGroup) GetServers ¶
func (sg *ServerGroup) GetServers(coordConn zkhelper.Conn) ([]*Server, error)
func (*ServerGroup) Master ¶
func (sg *ServerGroup) Master(coordConn zkhelper.Conn) (*Server, error)
func (*ServerGroup) RemoveServer ¶
func (sg *ServerGroup) RemoveServer(coordConn zkhelper.Conn, addr string) error
func (*ServerGroup) String ¶
func (sg *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.