election

package
v0.0.0-...-95b87ed Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefStartupGracePeriod       = time.Second * 15
	DefMembershipSampleInterval = time.Second
	DefLeaderAliveThreshold     = time.Second * 10
	DefLeaderElectionDuration   = time.Second * 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ElectionConfig

type ElectionConfig struct {
	StartupGracePeriod       time.Duration
	MembershipSampleInterval time.Duration
	LeaderAliveThreshold     time.Duration
	LeaderElectionDuration   time.Duration
}

type LeaderElectionAdapter

type LeaderElectionAdapter interface {
	Gossip(Msg)

	Accept() <-chan Msg

	CreateMessage(isDeclaration bool) Msg

	Peers() []Peer

	ReportMetrics(isLeader bool)
}

func NewAdapter

func NewAdapter(gossip gossip, pkiid common.PKIidType, channel common.ChannelID,
	metrics *metrics.ElectionMetrics) LeaderElectionAdapter

type LeaderElectionService

type LeaderElectionService interface {
	IsLeader() bool

	Stop()

	Yield()
}

func NewLeaderElectionService

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

type Msg

type Msg interface {
	SenderID() peerID

	IsProposal() bool

	IsDeclaration() bool
}

type Peer

type Peer interface {
	ID() peerID
}

Jump to

Keyboard shortcuts

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