etcd

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAbortTryLock is thrown when a user stops trying to seek the lock
	// by sending a signal to the stop chan, this is used to verify if the
	// operation succeeded
	ErrAbortTryLock = errors.New("lock operation aborted")
)

Functions

func New

func New(addrs []string, options *store.Config) (store.Store, error)

New creates a new Etcd client given a list of endpoints and an optional tls config

func Register

func Register()

Register registers etcd to libkv

Types

type Etcd

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

Etcd is the receiver type for the Store interface

func (*Etcd) AtomicDelete

func (s *Etcd) AtomicDelete(key string, previous *store.KVPair) (bool, error)

AtomicDelete deletes a value at "key" if the key has not been modified in the meantime, throws an error if this is the case

func (*Etcd) AtomicPut

func (s *Etcd) AtomicPut(key string, value []byte, previous *store.KVPair, opts *store.WriteOptions) (bool, *store.KVPair, error)

AtomicPut puts a value at "key" if the key has not been modified in the meantime, throws an error if this is the case

func (*Etcd) Close

func (s *Etcd) Close()

Close closes the client connection

func (*Etcd) Delete

func (s *Etcd) Delete(key string) error

Delete a value at "key"

func (*Etcd) DeleteTree

func (s *Etcd) DeleteTree(directory string) error

DeleteTree deletes a range of keys under a given directory

func (*Etcd) Exists

func (s *Etcd) Exists(key string) (bool, error)

Exists checks if the key exists inside the store

func (*Etcd) Get

func (s *Etcd) Get(key string) (pair *store.KVPair, err error)

Get the value at "key", returns the last modified index to use in conjunction to Atomic calls

func (*Etcd) List

func (s *Etcd) List(directory string) ([]*store.KVPair, error)

List child nodes of a given directory

func (*Etcd) NewLock

func (s *Etcd) NewLock(key string, options *store.LockOptions) (lock store.Locker, err error)

NewLock returns a handle to a lock struct which can be used to provide mutual exclusion on a key

func (*Etcd) Put

func (s *Etcd) Put(key string, value []byte, opts *store.WriteOptions) error

Put a value at "key"

func (*Etcd) Watch

func (s *Etcd) Watch(key string, stopCh <-chan struct{}) (<-chan *store.KVPair, error)

Watch for changes on a "key" It returns a channel that will receive changes or pass on errors. Upon creation, the current value will first be sent to the channel. Providing a non-nil stopCh can be used to stop watching.

func (*Etcd) WatchTree

func (s *Etcd) WatchTree(directory string, stopCh <-chan struct{}) (<-chan []*store.KVPair, error)

WatchTree watches for changes on a "directory" It returns a channel that will receive changes or pass on errors. Upon creating a watch, the current childs values will be sent to the channel. Providing a non-nil stopCh can be used to stop watching.

Jump to

Keyboard shortcuts

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