Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GetSetAPI ¶
type GetSetAPI interface { Get(ctx context.Context, key string, opts *etcd.GetOptions) (*etcd.Response, error) Set(ctx context.Context, key, value string, opts *etcd.SetOptions) (*etcd.Response, error) Delete(ctx context.Context, key string, opts *etcd.DeleteOptions) (*etcd.Response, error) }
Subset of the etcd.KeysAPI that includes CRUD functions.
type Maintainer ¶
type Maintainer struct { API GetSetAPI // How often keys "live" for in etcd. TTL time.Duration // How often we attempt to refresh etcd keys. This is slightly shorter // than the TTL so they we never "lose" keys. Interval time.Duration // Context generator used for making calls to etcd. Context func() context.Context // Etcd key this maintainer operates on. Key string // contains filtered or unexported fields }
The maintainer is used to keep a key set on an interval.
func NewDirMaintainer ¶
func NewDirMaintainer(api GetSetAPI, dir string, setContents func(m *Maintainer) error) *Maintainer
Creates and returns a new maintainer to keep a directory alive. It takes a function used to store things in the directory, in case the ttl gets missed.
func NewKeyMaintainer ¶
func NewKeyMaintainer(api GetSetAPI, key, value string) *Maintainer
Creates and returns a new maintainer to keep a kv pair alive.
func NewMaintainer ¶
func NewMaintainer(api GetSetAPI, key string, updater Updater, deleter Deleter) *Maintainer
Creates and returns a new maintainer, which calls the updater function periodically with a ttl.
func (*Maintainer) Errors ¶
func (m *Maintainer) Errors() <-chan error
Channel of errors that can occur as a result of etcd operations.
func (*Maintainer) Maintain ¶
func (m *Maintainer) Maintain()
Maintains the etcd key. Blocks until Close() is called. If an error occurs with etcd, we'll log it, you don't have to worry about it.
Click to show internal directories.
Click to hide internal directories.