Documentation ¶
Index ¶
- func CheckElapseAndWarn(start time.Time, message string, fields ...zap.Field) bool
- func CheckTnxBytesValueSizeAndWarn(kvs map[string][]byte) bool
- func CheckTnxStringValueSizeAndWarn(kvs map[string]string) bool
- func CheckValueSizeAndWarn(key string, value interface{}) bool
- func NewEtcdKV(client *clientv3.Client, rootPath string, options ...Option) *etcdKV
- func NewMetaKvFactory(rootPath string, etcdCfg *paramtable.EtcdConfig) (kv.MetaKv, error)
- func NewWatchKVFactory(rootPath string, etcdCfg *paramtable.EtcdConfig) (kv.WatchKV, error)
- type EmbedEtcdKV
- func (kv *EmbedEtcdKV) Close()
- func (kv *EmbedEtcdKV) CompareVersionAndSwap(ctx context.Context, key string, version int64, target string) (bool, error)
- func (kv *EmbedEtcdKV) CompareVersionAndSwapBytes(ctx context.Context, key string, version int64, target []byte, ...) (bool, error)
- func (kv *EmbedEtcdKV) GetConfig() embed.Config
- func (kv *EmbedEtcdKV) GetPath(key string) string
- func (kv *EmbedEtcdKV) Has(ctx context.Context, key string) (bool, error)
- func (kv *EmbedEtcdKV) HasPrefix(ctx context.Context, prefix string) (bool, error)
- func (kv *EmbedEtcdKV) Load(ctx context.Context, key string) (string, error)
- func (kv *EmbedEtcdKV) LoadBytes(ctx context.Context, key string) ([]byte, error)
- func (kv *EmbedEtcdKV) LoadBytesWithPrefix(ctx context.Context, key string) ([]string, [][]byte, error)
- func (kv *EmbedEtcdKV) LoadBytesWithPrefix2(ctx context.Context, key string) ([]string, [][]byte, []int64, error)
- func (kv *EmbedEtcdKV) LoadBytesWithRevision(ctx context.Context, key string) ([]string, [][]byte, int64, error)
- func (kv *EmbedEtcdKV) LoadWithPrefix(ctx context.Context, key string) ([]string, []string, error)
- func (kv *EmbedEtcdKV) MultiLoad(ctx context.Context, keys []string) ([]string, error)
- func (kv *EmbedEtcdKV) MultiLoadBytes(ctx context.Context, keys []string) ([][]byte, error)
- func (kv *EmbedEtcdKV) MultiRemove(ctx context.Context, keys []string) error
- func (kv *EmbedEtcdKV) MultiSave(ctx context.Context, kvs map[string]string) error
- func (kv *EmbedEtcdKV) MultiSaveAndRemove(ctx context.Context, saves map[string]string, removals []string, ...) error
- func (kv *EmbedEtcdKV) MultiSaveAndRemoveWithPrefix(ctx context.Context, saves map[string]string, removals []string, ...) error
- func (kv *EmbedEtcdKV) MultiSaveBytes(ctx context.Context, kvs map[string][]byte) error
- func (kv *EmbedEtcdKV) MultiSaveBytesAndRemove(ctx context.Context, saves map[string][]byte, removals []string) error
- func (kv *EmbedEtcdKV) MultiSaveBytesAndRemoveWithPrefix(ctx context.Context, saves map[string][]byte, removals []string) error
- func (kv *EmbedEtcdKV) Remove(ctx context.Context, key string) error
- func (kv *EmbedEtcdKV) RemoveWithPrefix(ctx context.Context, prefix string) error
- func (kv *EmbedEtcdKV) Save(ctx context.Context, key, value string) error
- func (kv *EmbedEtcdKV) SaveBytes(ctx context.Context, key string, value []byte) error
- func (kv *EmbedEtcdKV) SaveBytesWithLease(ctx context.Context, key string, value []byte, id clientv3.LeaseID) error
- func (kv *EmbedEtcdKV) WalkWithPrefix(ctx context.Context, prefix string, paginationSize int, ...) error
- func (kv *EmbedEtcdKV) Watch(ctx context.Context, key string) clientv3.WatchChan
- func (kv *EmbedEtcdKV) WatchWithPrefix(ctx context.Context, key string) clientv3.WatchChan
- func (kv *EmbedEtcdKV) WatchWithRevision(ctx context.Context, key string, revision int64) clientv3.WatchChan
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckElapseAndWarn ¶
CheckElapseAndWarn checks the elapsed time and warns if it is too long.
func CheckValueSizeAndWarn ¶
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 ¶
NewEmbededEtcdKV creates a new etcd kv.
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) 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 ¶
LoadWithPrefix returns all the keys and values with the given key prefix
func (*EmbedEtcdKV) MultiLoadBytes ¶
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) 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 ¶
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) 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.