Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewElection ¶
func NewElection(lg *zap.Logger, etcdCli *clientv3.Client, cfg ElectionConfig, id, key string, member Member) *election
NewElection creates an Election.
Types ¶
type Election ¶
type Election interface {
// Start starts compaining the owner.
Start(context.Context)
// ID returns the member ID.
ID() string
// GetOwnerID gets the owner ID.
GetOwnerID(ctx context.Context) (string, error)
// Close stops campaigning and retires if this member currently owns the key.
Close()
}
Election is used to campaign the owner and manage the owner information.
type ElectionConfig ¶
type ElectionConfig struct {
Timeout time.Duration
RetryIntvl time.Duration
RetryCnt uint64
SessionTTL int
}
func DefaultElectionConfig ¶
func DefaultElectionConfig(sessionTTL int) ElectionConfig
Click to show internal directories.
Click to hide internal directories.