Documentation ¶
Index ¶
- func IsAlreadyExist(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(context context.Context, key, value string, term time.Duration) error
- func (l *Client) AddWatch(key string, retry time.Duration, valuesC chan string)
- func (l *Client) AddWatchCallback(key string, retry time.Duration, fn CallbackFn)
- func (l *Client) Close() error
- func (l *Client) StepDown()
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyExist ¶
IsAlreadyExist determines if the specified error identifies a duplicate node event
func IsNotFound ¶
IsNotFound determines if the specified error identifies a node not found event
func IsWatchExpired ¶
IsWatchExpired determins 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 ¶
type CallbackFn func(key, prevValue, newValue string)
CallbackFn specifies callback that is called by AddWatchCallback whenever leader changes
type Client ¶
type Client struct {
// 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
func (*Client) AddWatch ¶
AddWatch starts watching the key for changes and sending them to the valuesC, the watch is stopped
func (*Client) AddWatchCallback ¶
func (l *Client) AddWatchCallback(key string, retry time.Duration, 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
type Config ¶
type Config struct { // ETCD defines etcd configuration, client will be instantiated // if passed ETCD *config.Config // Clock is a time provider Clock clockwork.Clock // Client is ETCD client will be used if passed Client client.Client }
Config sets leader election configuration options