Documentation ¶
Index ¶
- func IsAlreadyExists(err error) bool
- func IsContextError(err error) bool
- func IsNotFound(err error) bool
- func IsWatchExpired(err error) bool
- func NewUnlimitedExponentialBackOff() *backoff.ExponentialBackOff
- type CallbackFn
- type Client
- func (l *Client) AddVoter(ctx context.Context, key, value string, term time.Duration)
- func (l *Client) AddWatch(key string, valuesC chan string)
- func (l *Client) AddWatchCallback(key string, fn CallbackFn)
- func (l *Client) Close() error
- func (l *Client) RemoveVoter(ctx context.Context, key, value string, term time.Duration)
- func (l *Client) StepDown(ctx context.Context)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyExists ¶
IsAlreadyExists determines if the specified error identifies a duplicate node event
func IsContextError ¶
IsContextError returns true if the provided error indicates a canceled or expired context.
func IsNotFound ¶
IsNotFound determines if the specified error identifies a not found error
func IsWatchExpired ¶
IsWatchExpired determines if the specified error identifies an expired watch event
func NewUnlimitedExponentialBackOff ¶
func NewUnlimitedExponentialBackOff() *backoff.ExponentialBackOff
NewUnlimitedExponentialBackOff returns a new exponential backoff interval w/o time limit
Types ¶
type CallbackFn ¶
CallbackFn specifies callback that is called by AddWatchCallback whenever leader changes
type Client ¶
type Client struct { Config // contains filtered or unexported fields }
Client implements ETCD-backed leader election client that helps to elect new leaders for a given key and monitors the changes to the leaders
func (*Client) AddVoter ¶
AddVoter starts a goroutine that attempts to set the specified key to to the given value with the time-to-live value specified with term. The time-to-live value cannot be less than a second. After successfully setting the key, it attempts to renew the lease for the specified term indefinitely. The method is idempotent and does nothing if invoked multiple times
func (*Client) AddWatch ¶
AddWatch starts watching the key for changes and sending them to the valuesC until the client is stopped.
func (*Client) AddWatchCallback ¶
func (l *Client) AddWatchCallback(key string, fn CallbackFn)
AddWatchCallback adds the given callback to be invoked when changes are made to the specified key's value. The callback is called with new and previous values for the key. In the first call, both values are the same and reflect the value of the key at that moment
func (*Client) RemoveVoter ¶
RemoveVoter stops the voting loop.