etcd

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2018 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Ideally, this prefix would match the "_" used in the file backend, but
	// that prefix has special meaning in etcd. Specifically, it excludes those
	// entries from directory listings.
	Etcd2NodeFilePrefix = "."

	// The lock prefix can (and probably should) cause an entry to be excluded
	// from directory listings, so "_" works here.
	Etcd2NodeLockPrefix = "_"

	// The delimiter is the same as the `-C` flag of etcdctl.
	Etcd2MachineDelimiter = ","

	// The lock TTL matches the default that Consul API uses, 15 seconds.
	Etcd2LockTTL = 15 * time.Second

	// The amount of time to wait between the semaphore key renewals
	Etcd2LockRenewInterval = 5 * time.Second

	// The amount of time to wait if a watch fails before trying again.
	Etcd2WatchRetryInterval = time.Second

	// The number of times to re-try a failed watch before signaling that leadership is lost.
	Etcd2WatchRetryMax = 5
)

Variables

View Source
var (
	EtcdSyncConfigError          = errors.New("client setup failed: unable to parse etcd sync field in config")
	EtcdSyncClusterError         = errors.New("client setup failed: unable to sync etcd cluster")
	EtcdMultipleBootstrapError   = errors.New("client setup failed: multiple discovery or bootstrap flags specified, use either \"address\" or \"discovery_srv\"")
	EtcdAddressError             = errors.New("client setup failed: address must be valid URL (ex. 'scheme://host:port')")
	EtcdSemaphoreKeysEmptyError  = errors.New("lock queue is empty")
	EtcdLockHeldError            = errors.New("lock already held")
	EtcdLockNotHeldError         = errors.New("lock not held")
	EtcdSemaphoreKeyRemovedError = errors.New("semaphore key removed before lock acquisition")
	EtcdVersionUnknown           = errors.New("etcd: unknown API version")
)

Functions

func NewEtcdBackend

func NewEtcdBackend(conf map[string]string, logger log.Logger) (physical.Backend, error)

NewEtcdBackend constructs a etcd backend using a given machine address.

Types

type Etcd2Backend

type Etcd2Backend struct {
	// contains filtered or unexported fields
}

Etcd2Backend is a physical backend that stores data at specific prefix within etcd. It is used for most production situations as it allows Vault to run on multiple machines in a highly-available manner.

func (*Etcd2Backend) Delete

func (c *Etcd2Backend) Delete(ctx context.Context, key string) error

Delete is used to permanently delete an entry.

func (*Etcd2Backend) Get

func (c *Etcd2Backend) Get(ctx context.Context, key string) (*physical.Entry, error)

Get is used to fetch an entry.

func (*Etcd2Backend) HAEnabled

func (e *Etcd2Backend) HAEnabled() bool

HAEnabled indicates whether the HA functionality should be exposed. Currently always returns true.

func (*Etcd2Backend) List

func (c *Etcd2Backend) List(ctx context.Context, prefix string) ([]string, error)

List is used to list all the keys under a given prefix, up to the next prefix.

func (*Etcd2Backend) LockWith

func (c *Etcd2Backend) LockWith(key, value string) (physical.Lock, error)

Lock is used for mutual exclusion based on the given key.

func (*Etcd2Backend) Put

func (c *Etcd2Backend) Put(ctx context.Context, entry *physical.Entry) error

Put is used to insert or update an entry.

type Etcd2Lock

type Etcd2Lock struct {
	// contains filtered or unexported fields
}

Etcd2Lock implements a lock using and Etcd2 backend.

func (*Etcd2Lock) Lock

func (c *Etcd2Lock) Lock(stopCh <-chan struct{}) (doneCh <-chan struct{}, retErr error)

Lock attempts to acquire the lock by waiting for a new semaphore key in etcd to become the first in the queue and will block until it is successful or it receives a signal on the provided channel. The returned channel will be closed when the lock is lost, either by an explicit call to Unlock or by the associated semaphore key in etcd otherwise being deleted or expiring.

If the lock is currently held by this instance of Etcd2Lock, Lock will return an Etcd2LockHeldError error.

func (*Etcd2Lock) Unlock

func (c *Etcd2Lock) Unlock() error

Unlock releases the lock by deleting the associated semaphore key in etcd.

If the lock is not currently held by this instance of Etcd2Lock, Unlock will return an Etcd2LockNotHeldError error.

func (*Etcd2Lock) Value

func (c *Etcd2Lock) Value() (bool, string, error)

Value checks whether or not the lock is held by any instance of Etcd2Lock, including this one, and returns the current value.

type EtcdBackend

type EtcdBackend struct {
	// contains filtered or unexported fields
}

EtcdBackend is a physical backend that stores data at specific prefix within etcd. It is used for most production situations as it allows Vault to run on multiple machines in a highly-available manner.

func (*EtcdBackend) Delete

func (c *EtcdBackend) Delete(ctx context.Context, key string) error

func (*EtcdBackend) Get

func (c *EtcdBackend) Get(ctx context.Context, key string) (*physical.Entry, error)

func (*EtcdBackend) HAEnabled

func (e *EtcdBackend) HAEnabled() bool

func (*EtcdBackend) List

func (c *EtcdBackend) List(ctx context.Context, prefix string) ([]string, error)

func (*EtcdBackend) LockWith

func (c *EtcdBackend) LockWith(key, value string) (physical.Lock, error)

Lock is used for mutual exclusion based on the given key.

func (*EtcdBackend) Put

func (c *EtcdBackend) Put(ctx context.Context, entry *physical.Entry) error

type EtcdLock

type EtcdLock struct {
	// contains filtered or unexported fields
}

EtcdLock implements a lock using and etcd backend.

func (*EtcdLock) Lock

func (c *EtcdLock) Lock(stopCh <-chan struct{}) (<-chan struct{}, error)

func (*EtcdLock) Unlock

func (c *EtcdLock) Unlock() error

func (*EtcdLock) Value

func (c *EtcdLock) Value() (bool, string, error)

Jump to

Keyboard shortcuts

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