etcdkv

package
v0.0.0-...-34e0b2d Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 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(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(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(key string) (bool, error)

func (*EmbedEtcdKV) HasPrefix

func (kv *EmbedEtcdKV) HasPrefix(prefix string) (bool, error)

func (*EmbedEtcdKV) Load

func (kv *EmbedEtcdKV) Load(key string) (string, error)

Load returns value of the given key

func (*EmbedEtcdKV) LoadBytes

func (kv *EmbedEtcdKV) LoadBytes(key string) ([]byte, error)

LoadBytes returns value of the given key

func (*EmbedEtcdKV) LoadBytesWithPrefix

func (kv *EmbedEtcdKV) LoadBytesWithPrefix(key string) ([]string, [][]byte, error)

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

func (*EmbedEtcdKV) LoadBytesWithPrefix2

func (kv *EmbedEtcdKV) LoadBytesWithPrefix2(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(key string) ([]string, [][]byte, int64, error)

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

func (*EmbedEtcdKV) LoadWithPrefix

func (kv *EmbedEtcdKV) LoadWithPrefix(key string) ([]string, []string, error)

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

func (*EmbedEtcdKV) MultiLoad

func (kv *EmbedEtcdKV) MultiLoad(keys []string) ([]string, error)

MultiLoad returns values of a set of keys

func (*EmbedEtcdKV) MultiLoadBytes

func (kv *EmbedEtcdKV) MultiLoadBytes(keys []string) ([][]byte, error)

MultiLoadBytes returns values of a set of keys

func (*EmbedEtcdKV) MultiRemove

func (kv *EmbedEtcdKV) MultiRemove(keys []string) error

MultiRemove removes the keys in a transaction.

func (*EmbedEtcdKV) MultiSave

func (kv *EmbedEtcdKV) MultiSave(kvs map[string]string) error

MultiSave saves the key-value pairs in a transaction.

func (*EmbedEtcdKV) MultiSaveAndRemove

func (kv *EmbedEtcdKV) MultiSaveAndRemove(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(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(kvs map[string][]byte) error

MultiSaveBytes saves the key-value pairs in a transaction.

func (*EmbedEtcdKV) MultiSaveBytesAndRemove

func (kv *EmbedEtcdKV) MultiSaveBytesAndRemove(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(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(key string) error

Remove removes the key.

func (*EmbedEtcdKV) RemoveWithPrefix

func (kv *EmbedEtcdKV) RemoveWithPrefix(prefix string) error

RemoveWithPrefix removes the keys with given prefix.

func (*EmbedEtcdKV) Save

func (kv *EmbedEtcdKV) Save(key, value string) error

Save saves the key-value pair.

func (*EmbedEtcdKV) SaveBytes

func (kv *EmbedEtcdKV) SaveBytes(key string, value []byte) error

SaveBytes saves the key-value pair.

func (*EmbedEtcdKV) SaveBytesWithLease

func (kv *EmbedEtcdKV) SaveBytesWithLease(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(prefix string, paginationSize int, fn func([]byte, []byte) error) error

func (*EmbedEtcdKV) Watch

func (kv *EmbedEtcdKV) Watch(key string) clientv3.WatchChan

func (*EmbedEtcdKV) WatchWithPrefix

func (kv *EmbedEtcdKV) WatchWithPrefix(key string) clientv3.WatchChan

func (*EmbedEtcdKV) WatchWithRevision

func (kv *EmbedEtcdKV) WatchWithRevision(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