etcd

package
v0.10.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEtcdStore

func NewEtcdStore(ctx context.Context, config Config) (kvstore.Store, error)

NewEtcdStore creates a new instance of EtcdStore (singleton). It initializes the etcd client with the provided configuration and ensures only one instance is created.

Types

type Config

type Config struct {
	Endpoints   []string
	DialTimeout time.Duration
	Username    string
	Password    string
}

Config holds the configuration for EtcdStore.

type EtcdStore

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

EtcdStore represents an etcd.

func (*EtcdStore) Close

func (s *EtcdStore) Close() error

Close closes the etcd client. This is necessary to release resources associated with the client.

func (*EtcdStore) Delete

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

Delete removes a key-value pair from etcd without using a context.

func (*EtcdStore) DeleteWith

func (s *EtcdStore) DeleteWith(ctx context.Context, key string) error

DeleteWith removes a key-value pair from etcd using the provided context.

func (*EtcdStore) Get

func (s *EtcdStore) Get(key string) (string, error)

Get retrieves the value for a given key from etcd without using a context.

func (*EtcdStore) GetKv

func (s *EtcdStore) GetKv(key string) (kvstore.KeyValue, error)

GetKv retrieves a key-value pair from etcd without using a context.

func (*EtcdStore) GetKvList

func (s *EtcdStore) GetKvList(keyPrefix string) ([]kvstore.KeyValue, error)

GetKvList retrieves multiple key-value pairs with the given keyPrefix from etcd.

func (*EtcdStore) GetKvListWith

func (s *EtcdStore) GetKvListWith(ctx context.Context, keyPrefix string) ([]kvstore.KeyValue, error)

GetKvListWith retrieves multiple key-value pairs with the given keyPrefix from etcd using the provided context.

func (*EtcdStore) GetKvMap

func (s *EtcdStore) GetKvMap(keyPrefix string) (kvstore.KeyValueMap, error)

GetKvMap retrieves multiple key-value pairs with the given keyPrefix from etcd.

func (*EtcdStore) GetKvMapWith

func (s *EtcdStore) GetKvMapWith(ctx context.Context, keyPrefix string) (kvstore.KeyValueMap, error)

GetKvMapWith retrieves multiple key-value pairs with the given keyPrefix from etcd using the provided context.

func (*EtcdStore) GetKvWith

func (s *EtcdStore) GetKvWith(ctx context.Context, key string) (kvstore.KeyValue, error)

GetKvWith retrieves a key-value pair from etcd using the provided context.

func (*EtcdStore) GetList

func (s *EtcdStore) GetList(keyPrefix string) ([]string, error)

GetListWith retrieves multiple values for keys with the given keyPrefix from etcd.

func (*EtcdStore) GetListWith

func (s *EtcdStore) GetListWith(ctx context.Context, keyPrefix string) ([]string, error)

GetListWith retrieves multiple values for keys with the given keyPrefix from etcd using the provided context.

func (*EtcdStore) GetSortedKvList

func (s *EtcdStore) GetSortedKvList(keyPrefix string, sortBy clientv3.SortTarget, order clientv3.SortOrder) ([]kvstore.KeyValue, error)

GetSortedKvList retrieves multiple values for keys with the given keyPrefix, sortBy, and order from etcd.

func (*EtcdStore) GetSortedKvListWith

func (s *EtcdStore) GetSortedKvListWith(ctx context.Context, keyPrefix string, sortBy clientv3.SortTarget, order clientv3.SortOrder) ([]kvstore.KeyValue, error)

GetSortedKvListWith retrieves multiple values for keys with the given keyPrefix, sortBy, and order from etcd using the provided context.

func (*EtcdStore) GetWith

func (s *EtcdStore) GetWith(ctx context.Context, key string) (string, error)

GetWith retrieves the value for a given key from etcd using the provided context.

func (*EtcdStore) NewLock

func (s *EtcdStore) NewLock(ctx context.Context, session *concurrency.Session, lockKey string) (*concurrency.Mutex, error)

NewLock acquires a lock on the given key and returns the mutex. It uses the provided session to ensure the lock's lifecycle is tied to the session.

func (*EtcdStore) NewSession

func (s *EtcdStore) NewSession(ctx context.Context) (*concurrency.Session, error)

OpenSession creates a new etcd session. A session is needed for acquiring locks.

func (*EtcdStore) Put

func (s *EtcdStore) Put(key, value string) error

Put stores a key-value pair in etcd.

func (*EtcdStore) PutWith

func (s *EtcdStore) PutWith(ctx context.Context, key, value string) error

PutWith stores a key-value pair in etcd using the provided context.

func (*EtcdStore) WatchKey

func (s *EtcdStore) WatchKey(key string) clientv3.WatchChan

WatchKey watches for changes on the given key.

func (*EtcdStore) WatchKeyWith

func (s *EtcdStore) WatchKeyWith(ctx context.Context, key string) clientv3.WatchChan

WatchKeyWith watches for changes on the given key using the provided context.

func (*EtcdStore) WatchKeys

func (s *EtcdStore) WatchKeys(keyPrefix string) clientv3.WatchChan

WatchKeys watches for changes on keys with the given keyPrefix.

func (*EtcdStore) WatchKeysWith

func (s *EtcdStore) WatchKeysWith(ctx context.Context, keyPrefix string) clientv3.WatchChan

WatchKeysWith watches for changes on keys with the given keyPrefix using the provided context.

Jump to

Keyboard shortcuts

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