Documentation ¶
Index ¶
Constants ¶
View Source
const ( LocalPeer = "local" ReportMethod = "Cluster.Report" RequestMethod = "Cluster.Invoke" )
Variables ¶
Functions ¶
Types ¶
type Cluster ¶
集群有两个角色一个是主节点角色,一个是从节点角色。在同一时间,集群的节点只承担一种角色
func (*Cluster) Invoke ¶
func (c *Cluster) Invoke(msg *RequestPkt, resp *RespPkt) (err error)
Invoke called by a remote peer.
func (*Cluster) Ping ¶
func (c *Cluster) Ping(ping *PingRequest, unused *bool) error
Ping 集群内部接口,供远端主节点调用rpc.Client.Call("Cluster.Ping"...
func (*Cluster) Report ¶
func (c *Cluster) Report(msg *RequestPkt, resp *RespPkt) (err error)
Report 用于接收来自远端节点的内部广播,并调用本地Router.Register方法. 看作是内部节点对其他节点的广播,不对客户端开放 Called by remote peer
func (*Cluster) Vote ¶
func (c *Cluster) Vote(req *VoteRequest, resp *VoteResponse) error
Vote 集群内部接口,用于接收远端节点发出的投票rpc.Client.Go("Cluster.Vote"...
type PingRequest ¶
type PingRequest struct { // 主节点名称 Leader string // 选举的轮次 Term int // Ring hash signature that represents the cluster Signature string // 当前活动的集群名称集合 PeerValues []*PeerValue }
PingRequest 是主节点ping跟随节点时发送的数据
type RequestPkt ¶
type RequestPkt struct { // 发送这条请求的节点名称 PeerName string AppName string Paths []core.MethodPath PktType PktType // Ring hash signature of the node sending this request // Signature must match the signature of the receiver, otherwise the // Cluster is desynchronized. Signature string Pkt proto.Message }
maybe protobuf 这里需要定义交互需要的协议
type VoteRequest ¶
ClusterVoteRequest is a request from a leader candidate to a node to vote for the candidate.
type VoteResponse ¶
ClusterVoteResponse is a vote from a node.
Click to show internal directories.
Click to hide internal directories.