etcbeat

package module
v0.0.0-...-d981250 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deleter

type Deleter func(m *Maintainer) error

Function to delete the key.

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) Close

func (m *Maintainer) Close()

Closes the maintainer, deleting the key.

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.

type Updater

type Updater func(m *Maintainer) error

Updater function to be used in a maintainer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL