mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-12 08:23:58 +02:00
26 lines
500 B
Go
26 lines
500 B
Go
// Package leader provides leader election
|
|
package leader
|
|
|
|
// Leader provides leadership election
|
|
type Leader interface {
|
|
// elect leader
|
|
Elect(id string, opts ...ElectOption) (Elected, error)
|
|
// follow the leader
|
|
Follow() chan string
|
|
}
|
|
|
|
type Elected interface {
|
|
// id of leader
|
|
Id() string
|
|
// seek re-election
|
|
Reelect() error
|
|
// resign leadership
|
|
Resign() error
|
|
// observe leadership revocation
|
|
Revoked() chan bool
|
|
}
|
|
|
|
type Option func(o *Options)
|
|
|
|
type ElectOption func(o *ElectOptions)
|