mgmt

package
v0.2.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartSnapshotManager

func StartSnapshotManager(
	dataDir string,
	logFile string,
	threshold int64,
	period time.Duration,
	retain int,
	n *node.Node)

Types

type StateManager

type StateManager struct {
	// contains filtered or unexported fields
}

StateManager handles the aspects of the Raft protocol that require timing

func NewStateManager

func NewStateManager(
	resetFlag chan bool,
	electionTimeout time.Duration,
	electionJob func() bool,
	graceWindow time.Duration,
	graceEndJob func(),
	appendInterval time.Duration,
	appendJob func()) *StateManager

NewStateManager creates a StateManager with state initialized to Follower followFlag is a channel that indicates the node should reset the election timer, including becoming a Follower if the current state is Leader

electionTimeout is the duration a node should wait before starting an election. Events that delay an election should call `ResetTimer`. If the timer expires, the electionJob function is called

electionJob is a function that is called when the election timer expires, which should return a boolean designating whether the node should become a Leader (on true), or remain a Follower (on false)

appendInterval is the period between append requests when a node is a Leader

The ticker ticks on this period, and calls appendJob

appendJob is the task that a Leader should perform after each appendInterval

func (*StateManager) BecomeFollower

func (s *StateManager) BecomeFollower()

BecomeFollower explicitly changes the state to Follower

func (*StateManager) ResetTimer

func (s *StateManager) ResetTimer()

ResetTimer restarts the countdown on the election timer if the current state is Follower (does nothing if the current state is Leader)

Jump to

Keyboard shortcuts

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