Documentation
¶
Overview ¶
Package election provides leader election built on claim + fencing semantics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Name string
ParticipantID string
Lock FencedLock
Gate Gate
RenewEvery time.Duration
EventBuffer int // bounded; default 16
Clock func() time.Time
}
Config configures an Election.
type Election ¶
type Election struct {
// contains filtered or unexported fields
}
Election is a single named leadership contest.
func (*Election) IsLeader ¶
IsLeader reports local leadership belief (always confirm via token fencing for work).
type Event ¶
type Event struct {
Type EventType
Election string
Leader string
Token uint64
Time time.Time
Err string
}
Event is emitted on leadership changes.
type FencedLock ¶
type FencedLock interface {
Acquire(ctx context.Context, claim string) (token uint64, err error)
Release(ctx context.Context, claim string, token uint64) error
Renew(ctx context.Context, claim string, token uint64) error
}
FencedLock is the claim/fencing adapter (implemented by Runtime).
Click to show internal directories.
Click to hide internal directories.