etcd

package
v0.12.21 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 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) DeleteWithPrefix added in v0.12.12

func (s *EtcdStore) DeleteWithPrefix(keyPrefix string) error

DeleteWithPrefix removes all key-value pairs with the given prefix in a single etcd request.

func (*EtcdStore) DeleteWithPrefixWith added in v0.12.12

func (s *EtcdStore) DeleteWithPrefixWith(ctx context.Context, keyPrefix string) error

DeleteWithPrefixWith removes all key-value pairs with the given prefix in a single etcd request using the provided context.

func (*EtcdStore) Get

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

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

func (*EtcdStore) GetKeyList added in v0.12.9

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

GetKeyList retrieves only keys (no values) with the given keyPrefix from etcd.

func (*EtcdStore) GetKeyListWith added in v0.12.9

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

GetKeyListWith retrieves only keys with the given keyPrefix from etcd using the provided context. Using WithKeysOnly() avoids transferring value bytes, keeping the gRPC response small even for prefixes with thousands of large values.

func (*EtcdStore) GetKv

func (s *EtcdStore) GetKv(key string) (kvstore.KeyValue, bool, 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, bool, 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, bool, 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