Documentation
¶
Index ¶
- type Consensus
- func (c *Consensus) ClusterState() (*model.ClusterState, error)
- func (c *Consensus) CurrentState() model.ElectNode
- func (c *Consensus) IsLeader() bool
- func (c *Consensus) Leader() (*model.Node, error)
- func (c *Consensus) Run() (<-chan model.StateTransition, error)
- func (c *Consensus) Visualize() string
- type RpcHandler
- func (c *RpcHandler) HeartBeat(args *model.HeartBeatRequest, reply *model.HeartBeatResponse) error
- func (c *RpcHandler) Ping(args struct{}, reply *string) error
- func (c *RpcHandler) RequestVote(args *model.RequestVoteRequest, reply *model.RequestVoteResponse) error
- func (c *RpcHandler) Run() (<-chan model.StateTransition, error)
- func (c *RpcHandler) State(args struct{}, reply *model.ElectNode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Consensus ¶
type Consensus struct {
// contains filtered or unexported fields
}
func NewConsensus ¶
func (*Consensus) ClusterState ¶
func (c *Consensus) ClusterState() (*model.ClusterState, error)
ClusterState retrieves the current state of the cluster including all nodes.
func (*Consensus) CurrentState ¶
CurrentState returns the current election node state.
func (*Consensus) Leader ¶
Leader retrieves the current leader node from the cluster. It returns an error if no leader is found or there's an issue fetching the cluster state.
type RpcHandler ¶
type RpcHandler struct {
*Consensus
}
func NewConsensusRpcHandler ¶
func (*RpcHandler) HeartBeat ¶
func (c *RpcHandler) HeartBeat(args *model.HeartBeatRequest, reply *model.HeartBeatResponse) error
HeartBeat handles heartbeat request from peer node
func (*RpcHandler) Ping ¶
func (c *RpcHandler) Ping(args struct{}, reply *string) error
Ping handles ping request from peer node
func (*RpcHandler) RequestVote ¶
func (c *RpcHandler) RequestVote(args *model.RequestVoteRequest, reply *model.RequestVoteResponse) error
RequestVote handle vote request from peer node
func (*RpcHandler) Run ¶
func (c *RpcHandler) Run() (<-chan model.StateTransition, error)
Run starts the consensus Returns a channel of state transitions and an error
Click to show internal directories.
Click to hide internal directories.