election

package
v0.0.0-...-99016a9 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMsgExpirationTimeout

func GetMsgExpirationTimeout() time.Duration

GetMsgExpirationTimeout return leadership message expiration timeout

func SetLeaderAliveThreshold

func SetLeaderAliveThreshold(t time.Duration)

SetLeaderAliveThreshold configures leader election alive threshold

func SetLeaderElectionDuration

func SetLeaderElectionDuration(t time.Duration)

SetLeaderElectionDuration configures expected leadership election duration, interval to wait until leader election will be completed

func SetMembershipSampleInterval

func SetMembershipSampleInterval(t time.Duration)

SetMembershipSampleInterval setups/initializes the frequency the membership view should be checked

func SetStartupGracePeriod

func SetStartupGracePeriod(t time.Duration)

SetStartupGracePeriod configures startup grace period interval, the period of time to wait until election algorithm will start

Types

type LeaderElectionAdapter

type LeaderElectionAdapter interface {
	// Gossip gossips a message to other peers
	Gossip(Msg)

	// Accept returns a channel that emits messages
	Accept() <-chan Msg

	// CreateProposalMessage
	CreateMessage(isDeclaration bool) Msg

	// Peers returns a list of peers considered alive
	Peers() []Peer
}

LeaderElectionAdapter is used by the leader election module to send and receive messages and to get membership information

func NewAdapter

func NewAdapter(gossip gossip, pkiid common.PKIidType, channel common.ChainID) LeaderElectionAdapter

NewAdapter creates new leader election adapter

type LeaderElectionService

type LeaderElectionService interface {
	// IsLeader returns whether this peer is a leader or not
	IsLeader() bool

	// Stop stops the LeaderElectionService
	Stop()
}

LeaderElectionService is the object that runs the leader election algorithm

func NewLeaderElectionService

func NewLeaderElectionService(adapter LeaderElectionAdapter, id string, callback leadershipCallback) LeaderElectionService

NewLeaderElectionService returns a new LeaderElectionService

type Msg

type Msg interface {
	// SenderID returns the ID of the peer sent the message
	SenderID() peerID
	// IsProposal returns whether this message is a leadership proposal
	IsProposal() bool
	// IsDeclaration returns whether this message is a leadership declaration
	IsDeclaration() bool
}

Msg describes a message sent from a remote peer

type Peer

type Peer interface {
	// ID returns the ID of the peer
	ID() peerID
}

Peer describes a remote peer

Jump to

Keyboard shortcuts

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