Documentation ¶
Index ¶
Constants ¶
View Source
const Type primitive.Type = "Election"
Type is the election type
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // GetElection gets the Election instance of the given name GetElection(ctx context.Context, name string, opts ...Option) (Election, error) }
Client provides an API for creating Elections
type Election ¶
type Election interface { primitive.Primitive // ID returns the ID of the instance of the election ID() string // GetTerm gets the current election term GetTerm(ctx context.Context) (*Term, error) // Enter enters the instance into the election Enter(ctx context.Context) (*Term, error) // Leave removes the instance from the election Leave(ctx context.Context) (*Term, error) // Anoint assigns leadership to the instance with the given ID Anoint(ctx context.Context, id string) (*Term, error) // Promote increases the priority of the instance with the given ID in the election queue Promote(ctx context.Context, id string) (*Term, error) // Evict removes the instance with the given ID from the election Evict(ctx context.Context, id string) (*Term, error) // Watch watches the election for changes Watch(ctx context.Context, c chan<- *Event) error }
Election provides distributed leader election
type Event ¶
type Event struct { // Type is the type of the event Type EventType // Term is the term that occurs as a result of the election event Term Term }
Event is an election event
type EventType ¶
type EventType string
EventType is the type of an Election event
const ( // EventChanged indicates the election term changed EventChanged EventType = "changed" )
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is an election option
type Term ¶
type Term struct { // ID is a globally unique, monotonically increasing term number ID uint64 // Leader is the ID of the leader that was elected Leader string // Candidates is a list of candidates currently participating in the election Candidates []string }
Term is a leadership term A term is guaranteed to have a monotonically increasing, globally unique ID.
Click to show internal directories.
Click to hide internal directories.