election

package
v0.0.0-...-fbe82ab Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 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返回领导层消息过期超时

func SetLeaderAliveThreshold

func SetLeaderAliveThreshold(t time.Duration)

setLeaderAliveThreshold配置领导者选举活动阈值

func SetLeaderElectionDuration

func SetLeaderElectionDuration(t time.Duration)

setLeaderRelationDuration配置预期的领导层选举持续时间, 等待领导人选举完成的时间间隔

func SetMembershipSampleInterval

func SetMembershipSampleInterval(t time.Duration)

setmembershipsampleinterval设置/初始化 membership view should be checked

func SetStartupGracePeriod

func SetStartupGracePeriod(t time.Duration)

setStartupGracePeriod配置启动宽限期间隔, the period of time to wait until election algorithm will start

Types

type LeaderElectionAdapter

type LeaderElectionAdapter interface {
	//流言蜚语向其他同龄人传递信息
	Gossip(Msg)

	//accept返回发出消息的通道
	Accept() <-chan Msg

	//创建建议消息
	CreateMessage(isDeclaration bool) Msg

	//peers返回被认为是活动的对等方的列表
	Peers() []Peer
}

领导选举模块使用Lead Error适配器 发送和接收消息以及获取成员信息

func NewAdapter

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

NewAdapter创建新的Leader Election适配器

type LeaderElectionService

type LeaderElectionService interface {
	//Isleader返回这个同伴是否是领导者
	IsLeader() bool

	//停止停止LeadRelationService
	Stop()

	//屈服于放弃领导直到选出新的领导,
	//或者超时过期
	Yield()
}

LeaderRelationService是运行Leader选举算法的对象

func NewLeaderElectionService

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

NewLeaderRelationService返回新的LeaderRelationService

type Msg

type Msg interface {
	//senderid返回发送消息的对等方的ID
	SenderID() peerID
	//IsProposal返回此消息是否是领导层建议
	IsProposal() bool
	//IsDeclaration returns whether this message is a leadership declaration
	IsDeclaration() bool
}

msg描述从远程对等机发送的消息

type Peer

type Peer interface {
	//ID返回对等机的ID
	ID() peerID
}

对等机描述远程对等机

Jump to

Keyboard shortcuts

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