etcdv3

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package etcdv3 contains the etcd v3 store implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

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 kvdb.

Types

type EtcdV3

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

EtcdV3 is the receiver type for the Store interface.

func (*EtcdV3) AtomicDelete

func (s *EtcdV3) AtomicDelete(ctx context.Context, 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 (*EtcdV3) AtomicPut

func (s *EtcdV3) AtomicPut(ctx context.Context, 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 (*EtcdV3) Close

func (s *EtcdV3) Close() error

Close closes the client connection.

func (*EtcdV3) Delete

func (s *EtcdV3) Delete(ctx context.Context, key string) error

Delete a value at "key".

func (*EtcdV3) DeleteTree

func (s *EtcdV3) DeleteTree(ctx context.Context, directory string) error

DeleteTree deletes a range of keys under a given directory.

func (*EtcdV3) Exists

func (s *EtcdV3) Exists(ctx context.Context, key string, opts *store.ReadOptions) (bool, error)

Exists checks if the key exists inside the store.

func (*EtcdV3) Get

func (s *EtcdV3) Get(ctx context.Context, key string, opts *store.ReadOptions) (pair *store.KVPair, err error)

Get the value at "key". Returns the last modified index to use in conjunction to Atomic calls.

func (*EtcdV3) List

func (s *EtcdV3) List(ctx context.Context, directory string, opts *store.ReadOptions) ([]*store.KVPair, error)

List child nodes of a given directory.

func (*EtcdV3) NewLock

func (s *EtcdV3) NewLock(_ context.Context, 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 (*EtcdV3) Put

func (s *EtcdV3) Put(ctx context.Context, key string, value []byte, opts *store.WriteOptions) error

Put a value at "key".

func (*EtcdV3) Watch

func (s *EtcdV3) Watch(ctx context.Context, key string, stopCh <-chan struct{}, opts *store.ReadOptions) (<-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 (*EtcdV3) WatchTree

func (s *EtcdV3) WatchTree(ctx context.Context, directory string, stopCh <-chan struct{}, opts *store.ReadOptions) (<-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 children 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