Documentation ¶
Index ¶
- Constants
- func EncodeMessage(msgType uint16, nodeId uint64, character CharacterType) [12]byte
- type CharacterType
- type Config
- type EBully
- func (e *EBully) Character() NodeCharacterType
- func (e *EBully) ID() uint64
- func (e *EBully) Leave() error
- func (e *EBully) Meet(masterAddr string) (err error)
- func (e *EBully) PeerIds() []uint64
- func (e *EBully) PeerList() []*nodepb.NodeInfo
- func (e *EBully) Shutdown() error
- func (e *EBully) Start()
- func (e *EBully) Weight() int
- type Node
- func (n *Node) GetCharacter() int64
- func (n *Node) HearbeatRpc(ctx context.Context, req *nodepb.NodeInfo) (resp *nodepb.HearbeatResp, err error)
- func (n *Node) Leave() error
- func (n *Node) LeaveRpc(ctx context.Context, req *nodepb.LeaveReq) (resp *nodepb.LeaveResp, err error)
- func (n *Node) MeetRpc(ctx context.Context, req *nodepb.NodeInfo) (resp *nodepb.MeetResp, err error)
- func (n *Node) NodeMessageRpc(ctx context.Context, req *nodepb.MessageReq) (resp *nodepb.MessageResp, err error)
- func (n *Node) PeerIdListRpc(ctx context.Context, req *nodepb.EmptyMessage) (resp *nodepb.NodeIdListResp, err error)
- func (n *Node) PeerIds() []uint64
- func (n *Node) PeerInfos() []*nodepb.NodeInfo
- func (n *Node) PeerInfosRpc(ctx context.Context, req *nodepb.EmptyMessage) (resp *nodepb.NodeInfoResp, err error)
- func (n *Node) SetCharacter(c int64)
- func (n *Node) SetMasterMeta(nodeinfo *nodepb.NodeInfo) *Node
- func (n *Node) Start()
- func (n *Node) Stop() error
- type NodeCharacterType
- type NodeMeta
- func (meta *NodeMeta) Address() string
- func (meta *NodeMeta) InstanceID() uint64
- func (meta *NodeMeta) InstanceWeight() int
- func (meta *NodeMeta) Leave(nodeInfo *node.LeaveReq) (*node.LeaveResp, error)
- func (meta *NodeMeta) Meet(msg *node.NodeInfo) (*node.MeetResp, error)
- func (meta *NodeMeta) NodeInfoList() (*node.NodeInfoResp, error)
- func (meta *NodeMeta) SendHearbeat(nodeInfo *node.NodeInfo) (*node.HearbeatResp, error)
- func (meta *NodeMeta) ServiceAddress() string
- func (meta *NodeMeta) UpdateId(id uint64) *NodeMeta
- func (meta *NodeMeta) UpdateInfo(nodeInfo *node.NodeInfo) *NodeMeta
- type NodeMetaList
- type SafeNodeMetaList
- func (so *SafeNodeMetaList) Append(node *NodeMeta)
- func (so *SafeNodeMetaList) BinarySearch(target uint64) int
- func (so *SafeNodeMetaList) Broadcast(msg *node.MessageReq)
- func (so *SafeNodeMetaList) DeleteIndex(i int)
- func (so *SafeNodeMetaList) SafeDo(f func(so *SafeNodeMetaList))
- func (so *SafeNodeMetaList) Sort()
Constants ¶
View Source
const ( TemporaryCharacter = iota Master Follower )
View Source
const ( NodeUp = iota NodeDown MasterChange )
View Source
const (
MaxInt64 = 1<<64 - 1
)
Variables ¶
This section is empty.
Functions ¶
func EncodeMessage ¶
func EncodeMessage(msgType uint16, nodeId uint64, character CharacterType) [12]byte
Types ¶
type CharacterType ¶
type CharacterType int
func DecodeMessage ¶
func DecodeMessage(msg []byte) (msgType uint16, nodeId uint64, character CharacterType)
type EBully ¶
type EBully struct {
// contains filtered or unexported fields
}
func (*EBully) Character ¶
func (e *EBully) Character() NodeCharacterType
type Node ¶
type Node struct { nodepb.UnsafeNodeServer // contains filtered or unexported fields }
func (*Node) HearbeatRpc ¶
func (n *Node) HearbeatRpc(ctx context.Context, req *nodepb.NodeInfo) (resp *nodepb.HearbeatResp, err error)
Hearbeat 接收心跳
func (*Node) LeaveRpc ¶
func (n *Node) LeaveRpc(ctx context.Context, req *nodepb.LeaveReq) (resp *nodepb.LeaveResp, err error)
ShutdownRpc node down RPC
func (*Node) MeetRpc ¶
func (n *Node) MeetRpc(ctx context.Context, req *nodepb.NodeInfo) (resp *nodepb.MeetResp, err error)
Meet加入集群,返回ack=true时,表明当前节点应该为主节点,收到响应信息的节点为从节点 ack=false时,表明当前节点为从节点,收到响应信息的节点参考Redirect字段去寻找主节点
func (*Node) NodeMessageRpc ¶
func (n *Node) NodeMessageRpc(ctx context.Context, req *nodepb.MessageReq) (resp *nodepb.MessageResp, err error)
NodeMessage接受消息
func (*Node) PeerIdListRpc ¶
func (n *Node) PeerIdListRpc(ctx context.Context, req *nodepb.EmptyMessage) (resp *nodepb.NodeIdListResp, err error)
Peers获取集群节点
func (*Node) PeerInfosRpc ¶
func (n *Node) PeerInfosRpc(ctx context.Context, req *nodepb.EmptyMessage) (resp *nodepb.NodeInfoResp, err error)
Peers获取集群节点
type NodeCharacterType ¶
type NodeCharacterType int
func (NodeCharacterType) String ¶
func (nct NodeCharacterType) String() string
type NodeMeta ¶
type NodeMeta struct {
// contains filtered or unexported fields
}
func NewNodeMeta ¶
func (*NodeMeta) InstanceID ¶
UinqueId return the id of node ,it implement the interface named loadbalance.Instance.
func (*NodeMeta) InstanceWeight ¶
Weight return the its memory capacity as the weight , it implement the interface named loadbalance.Instance.
func (*NodeMeta) NodeInfoList ¶
func (meta *NodeMeta) NodeInfoList() (*node.NodeInfoResp, error)
func (*NodeMeta) SendHearbeat ¶
SendHearbeat to the address of node in the node meta
func (*NodeMeta) ServiceAddress ¶
Address return the address string
type NodeMetaList ¶
type NodeMetaList []*NodeMeta
func (NodeMetaList) Len ¶
func (metaList NodeMetaList) Len() int
func (NodeMetaList) Less ¶
func (metaList NodeMetaList) Less(i, j int) bool
func (NodeMetaList) Swap ¶
func (metaList NodeMetaList) Swap(i, j int)
type SafeNodeMetaList ¶
type SafeNodeMetaList struct { NodeMetaList // contains filtered or unexported fields }
func (*SafeNodeMetaList) Append ¶
func (so *SafeNodeMetaList) Append(node *NodeMeta)
func (*SafeNodeMetaList) BinarySearch ¶
func (so *SafeNodeMetaList) BinarySearch(target uint64) int
func (*SafeNodeMetaList) Broadcast ¶
func (so *SafeNodeMetaList) Broadcast(msg *node.MessageReq)
func (*SafeNodeMetaList) DeleteIndex ¶
func (so *SafeNodeMetaList) DeleteIndex(i int)
func (*SafeNodeMetaList) SafeDo ¶
func (so *SafeNodeMetaList) SafeDo(f func(so *SafeNodeMetaList))
func (*SafeNodeMetaList) Sort ¶
func (so *SafeNodeMetaList) Sort()
Click to show internal directories.
Click to hide internal directories.