consensus

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

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 NewConsensus(
	node model.ElectNode,
	trans model.Transport,
	transConfig model.TransportConfig,
	cfg *config.Config,
	logger *slog.Logger) (*Consensus, error)

func (*Consensus) ClusterState

func (c *Consensus) ClusterState() (*model.ClusterState, error)

ClusterState retrieves the current state of the cluster including all nodes.

func (*Consensus) CurrentState

func (c *Consensus) CurrentState() model.NodeState

CurrentState returns the current election node state.

func (*Consensus) HandleRequest added in v1.0.4

func (c *Consensus) HandleRequest(request *model.Request, response *model.Response) error

func (*Consensus) HeartBeat added in v1.0.4

func (c *Consensus) HeartBeat(args *model.HeartBeatRequest, reply *model.HeartBeatResponse) error

HeartBeat handles heartbeat request from peer node

func (*Consensus) IsLeader

func (c *Consensus) IsLeader() bool

IsLeader determines whether the current node is the leader node.

func (*Consensus) Leader

func (c *Consensus) Leader() (*model.ElectNode, error)

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.

func (*Consensus) RequestVote added in v1.0.4

func (c *Consensus) RequestVote(args *model.RequestVoteRequest, reply *model.RequestVoteResponse) error

RequestVote handle vote request from peer node

func (*Consensus) Run

func (c *Consensus) Run() (<-chan model.StateTransition, error)

Run starts the consensus Returns a channel of state transitions and an error

func (*Consensus) State added in v1.0.4

func (c *Consensus) State(reply *model.NodeWithState) error

State return current node state

func (*Consensus) Visualize

func (c *Consensus) Visualize() string

Visualize returns a visualization of the current consensus state machine in Graphviz format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL