Documentation ¶
Index ¶
- type Candidate
- func (c *Candidate) Campaign(ctx context.Context) error
- func (c *Candidate) Close() error
- func (c *Candidate) GetCurLeaderInfo(ctx context.Context) (string, string, int64, error)
- func (c *Candidate) Init() error
- func (c *Candidate) IsCurLeaderAtMe(ctx context.Context) (bool, error)
- func (c *Candidate) MyName() string
- func (c *Candidate) MyTerm() string
- func (c *Candidate) Proclaim(ctx context.Context, newName string) error
- func (c *Candidate) Resign(ctx context.Context) error
- type Observer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate struct {
// contains filtered or unexported fields
}
func NewCandidate ¶
func (*Candidate) Campaign ¶
Campaign When starting the campaign, ctx only controls the waiting time for the campaign. If elected, the status of becoming the leader will always be maintained, and it has nothing to do with ctx.
func (*Candidate) Close ¶
Close After closing the session, the current election or election will be withdrawn, and this instance will no longer be available. Calling Campaign again will report an error.
func (*Candidate) GetCurLeaderInfo ¶
GetCurLeaderInfo Get the information about the current leader in the cluster. If no one is elected as the leader in the current cluster, then return concurrency.ErrElectionNoLeader error.
func (*Candidate) IsCurLeaderAtMe ¶
func (*Candidate) Proclaim ¶
Proclaim If you are the leader, you can change the name of yourself and announce it to its members during this period; If you are not the current leader, report an error and return concurrency.ErrElectionNotLeader.