etcdkv

package
v0.10.3-0...-a99c92e Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckElapseAndWarn

func CheckElapseAndWarn(start time.Time, message string, fields ...zap.Field) bool

CheckElapseAndWarn checks the elapsed time and warns if it is too long.

func CheckTnxBytesValueSizeAndWarn

func CheckTnxBytesValueSizeAndWarn(kvs map[string][]byte) bool

func CheckTnxStringValueSizeAndWarn

func CheckTnxStringValueSizeAndWarn(kvs map[string]string) bool

func CheckValueSizeAndWarn

func CheckValueSizeAndWarn(key string, value interface{}) bool

func NewEtcdKV

func NewEtcdKV(client *clientv3.Client, rootPath string, options ...Option) *etcdKV

NewEtcdKV creates a new etcd kv.

func NewMetaKvFactory

func NewMetaKvFactory(rootPath string, etcdCfg *paramtable.EtcdConfig) (kv.MetaKv, error)

NewMetaKvFactory returns an object that implements the kv.MetaKv interface using etcd. The UseEmbedEtcd in the param is used to determine whether the etcd service is external or embedded.

func NewWatchKVFactory

func NewWatchKVFactory(rootPath string, etcdCfg *paramtable.EtcdConfig) (kv.WatchKV, error)

NewWatchKVFactory returns an object that implements the kv.WatchKV interface using etcd. The UseEmbedEtcd in the param is used to determine whether the etcd service is external or embedded.

Types

type EmbedEtcdKV

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

EmbedEtcdKV use embedded Etcd instance as a KV storage

func NewEmbededEtcdKV

func NewEmbededEtcdKV(cfg *embed.Config, rootPath string, options ...Option) (*EmbedEtcdKV, error)

NewEmbededEtcdKV creates a new etcd kv.

func (*EmbedEtcdKV) Close

func (kv *EmbedEtcdKV) Close()

Close closes the embedded etcd

func (*EmbedEtcdKV) CompareVersionAndSwap

func (kv *EmbedEtcdKV) CompareVersionAndSwap(ctx context.Context, key string, version int64, target string) (bool, error)

CompareVersionAndSwap compares the existing key-value's version with version, and if they are equal, the target is stored in etcd.

func (*EmbedEtcdKV) CompareVersionAndSwapBytes

func (kv *EmbedEtcdKV) CompareVersionAndSwapBytes(ctx context.Context, key string, version int64, target []byte, opts ...clientv3.OpOption) (bool, error)

CompareVersionAndSwapBytes compares the existing key-value's version with version, and if they are equal, the target is stored in etcd.

func (*EmbedEtcdKV) GetConfig

func (kv *EmbedEtcdKV) GetConfig() embed.Config

func (*EmbedEtcdKV) GetPath

func (kv *EmbedEtcdKV) GetPath(key string) string

GetPath returns the full path by given key

func (*EmbedEtcdKV) Has

func (kv *EmbedEtcdKV) Has(ctx context.Context, key string) (bool, error)

func (*EmbedEtcdKV) HasPrefix

func (kv *EmbedEtcdKV) HasPrefix(ctx context.Context, prefix string) (bool, error)

func (*EmbedEtcdKV) Load

func (kv *EmbedEtcdKV) Load(ctx context.Context, key string) (string, error)

Load returns value of the given key

func (*EmbedEtcdKV) LoadBytes

func (kv *EmbedEtcdKV) LoadBytes(ctx context.Context, key string) ([]byte, error)

LoadBytes returns value of the given key

func (*EmbedEtcdKV) LoadBytesWithPrefix

func (kv *EmbedEtcdKV) LoadBytesWithPrefix(ctx context.Context, key string) ([]string, [][]byte, error)

LoadBytesWithPrefix returns all the keys and values with the given key prefix

func (*EmbedEtcdKV) LoadBytesWithPrefix2

func (kv *EmbedEtcdKV) LoadBytesWithPrefix2(ctx context.Context, key string) ([]string, [][]byte, []int64, error)

LoadBytesWithPrefix2 returns all the keys and values with versions by the given key prefix

func (*EmbedEtcdKV) LoadBytesWithRevision

func (kv *EmbedEtcdKV) LoadBytesWithRevision(ctx context.Context, key string) ([]string, [][]byte, int64, error)

LoadBytesWithRevision returns keys, values and revision with given key prefix.

func (*EmbedEtcdKV) LoadWithPrefix

func (kv *EmbedEtcdKV) LoadWithPrefix(ctx context.Context, key string) ([]string, []string, error)

LoadWithPrefix returns all the keys and values with the given key prefix

func (*EmbedEtcdKV) MultiLoad

func (kv *EmbedEtcdKV) MultiLoad(ctx context.Context, keys []string) ([]string, error)

MultiLoad returns values of a set of keys

func (*EmbedEtcdKV) MultiLoadBytes

func (kv *EmbedEtcdKV) MultiLoadBytes(ctx context.Context, keys []string) ([][]byte, error)

MultiLoadBytes returns values of a set of keys

func (*EmbedEtcdKV) MultiRemove

func (kv *EmbedEtcdKV) MultiRemove(ctx context.Context, keys []string) error

MultiRemove removes the keys in a transaction.

func (*EmbedEtcdKV) MultiSave

func (kv *EmbedEtcdKV) MultiSave(ctx context.Context, kvs map[string]string) error

MultiSave saves the key-value pairs in a transaction.

func (*EmbedEtcdKV) MultiSaveAndRemove

func (kv *EmbedEtcdKV) MultiSaveAndRemove(ctx context.Context, saves map[string]string, removals []string, preds ...predicates.Predicate) error

MultiSaveAndRemove saves the key-value pairs and removes the keys in a transaction.

func (*EmbedEtcdKV) MultiSaveAndRemoveWithPrefix

func (kv *EmbedEtcdKV) MultiSaveAndRemoveWithPrefix(ctx context.Context, saves map[string]string, removals []string, preds ...predicates.Predicate) error

MultiSaveAndRemoveWithPrefix saves kv in @saves and removes the keys with given prefix in @removals.

func (*EmbedEtcdKV) MultiSaveBytes

func (kv *EmbedEtcdKV) MultiSaveBytes(ctx context.Context, kvs map[string][]byte) error

MultiSaveBytes saves the key-value pairs in a transaction.

func (*EmbedEtcdKV) MultiSaveBytesAndRemove

func (kv *EmbedEtcdKV) MultiSaveBytesAndRemove(ctx context.Context, saves map[string][]byte, removals []string) error

MultiSaveBytesAndRemove saves the key-value pairs and removes the keys in a transaction.

func (*EmbedEtcdKV) MultiSaveBytesAndRemoveWithPrefix

func (kv *EmbedEtcdKV) MultiSaveBytesAndRemoveWithPrefix(ctx context.Context, saves map[string][]byte, removals []string) error

MultiSaveBytesAndRemoveWithPrefix saves kv in @saves and removes the keys with given prefix in @removals.

func (*EmbedEtcdKV) Remove

func (kv *EmbedEtcdKV) Remove(ctx context.Context, key string) error

Remove removes the key.

func (*EmbedEtcdKV) RemoveWithPrefix

func (kv *EmbedEtcdKV) RemoveWithPrefix(ctx context.Context, prefix string) error

RemoveWithPrefix removes the keys with given prefix.

func (*EmbedEtcdKV) Save

func (kv *EmbedEtcdKV) Save(ctx context.Context, key, value string) error

Save saves the key-value pair.

func (*EmbedEtcdKV) SaveBytes

func (kv *EmbedEtcdKV) SaveBytes(ctx context.Context, key string, value []byte) error

SaveBytes saves the key-value pair.

func (*EmbedEtcdKV) SaveBytesWithLease

func (kv *EmbedEtcdKV) SaveBytesWithLease(ctx context.Context, key string, value []byte, id clientv3.LeaseID) error

SaveBytesWithLease is a function to put value in etcd with etcd lease options.

func (*EmbedEtcdKV) WalkWithPrefix

func (kv *EmbedEtcdKV) WalkWithPrefix(ctx context.Context, prefix string, paginationSize int, fn func([]byte, []byte) error) error

func (*EmbedEtcdKV) Watch

func (kv *EmbedEtcdKV) Watch(ctx context.Context, key string) clientv3.WatchChan

func (*EmbedEtcdKV) WatchWithPrefix

func (kv *EmbedEtcdKV) WatchWithPrefix(ctx context.Context, key string) clientv3.WatchChan

func (*EmbedEtcdKV) WatchWithRevision

func (kv *EmbedEtcdKV) WatchWithRevision(ctx context.Context, key string, revision int64) clientv3.WatchChan

type Option

type Option func(*etcdOpt)

func WithRequestTimeout

func WithRequestTimeout(timeout time.Duration) Option

Jump to

Keyboard shortcuts

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