Documentation ¶
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ElectionConfig ¶
type LeaderElectionAdapter ¶
type LeaderElectionAdapter interface { // Gossip gossips a message to other peers Gossip(*pgossip.GossipMessage) // Accept returns a channel that emits messages Accept() <-chan *pgossip.GossipMessage // CreateProposalMessage CreateMessage(isDeclaration bool) *pgossip.GossipMessage // Peers returns a list of peers considered alive Peers() []utils.NetworkMember // ReportMetrics sends a report to the metrics server about a leadership status ReportMetrics(isLeader bool) }
LeaderElectionAdapter 在 leader 选举模块中被用来接收/发送消息。
func NewAdapter ¶
func NewAdapter(gossip gossip, pkiid utils.PKIidType, channel utils.ChannelID, metrics *metrics.ElectionMetrics, logger mlog.Logger) 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() // Yield relinquishes the leadership until a new leader is elected, // or a timeout expires Yield() }
LeaderElectionService is the object that runs the leader election algorithm
func NewLeaderElectionService ¶
func NewLeaderElectionService(adapter LeaderElectionAdapter, id utils.PKIidType, callback leadershipCallback, config ElectionConfig, logger mlog.Logger) LeaderElectionService
NewLeaderElectionService returns a new LeaderElectionService
Click to show internal directories.
Click to hide internal directories.