Documentation
¶
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ElectionConfig ¶
type LeaderElectionAdapter ¶
type LeaderElectionAdapter interface {
Gossip(*pbgossip.GossipMessage)
Accept() <-chan *pbgossip.GossipMessage
CreateMessage(isDeclaration bool) *pbgossip.GossipMessage
// Peers 返回与自己在同一组织内的 alive 成员信息。
Peers() []discovery.NetworkMember
ReportMetrics(isLeader bool)
Stop()
}
func NewAdapter ¶
func NewAdapter(gossip gossip, id common.PKIid, channelID common.ChannelID, metrics *metrics.ElectionMetrics, endpoint string) LeaderElectionAdapter
type LeaderElectionService ¶
type LeaderElectionService interface {
// IsLeader 返回该 peer 是否是 leader。
IsLeader() bool
// Stop 停止服务。
Stop()
// Waive 方法表明放弃领导权,直到选出新的领导者或超时结束。
Waive()
}
func NewLeaderElectionService ¶
func NewLeaderElectionService(adapter LeaderElectionAdapter, id common.PKIid, callback leadershipCallback, config ElectionConfig, endpoint string) LeaderElectionService
Click to show internal directories.
Click to hide internal directories.


