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(key string, version int64, target string) (bool, error)
- func (kv *EmbedEtcdKV) CompareVersionAndSwapBytes(key string, version int64, target []byte, opts ...clientv3.OpOption) (bool, error)
- func (kv *EmbedEtcdKV) GetConfig() embed.Config
- func (kv *EmbedEtcdKV) GetPath(key string) string
- func (kv *EmbedEtcdKV) Has(key string) (bool, error)
- func (kv *EmbedEtcdKV) HasPrefix(prefix string) (bool, error)
- func (kv *EmbedEtcdKV) Load(key string) (string, error)
- func (kv *EmbedEtcdKV) LoadBytes(key string) ([]byte, error)
- func (kv *EmbedEtcdKV) LoadBytesWithPrefix(key string) ([]string, [][]byte, error)
- func (kv *EmbedEtcdKV) LoadBytesWithPrefix2(key string) ([]string, [][]byte, []int64, error)
- func (kv *EmbedEtcdKV) LoadBytesWithRevision(key string) ([]string, [][]byte, int64, error)
- func (kv *EmbedEtcdKV) LoadWithPrefix(key string) ([]string, []string, error)
- func (kv *EmbedEtcdKV) MultiLoad(keys []string) ([]string, error)
- func (kv *EmbedEtcdKV) MultiLoadBytes(keys []string) ([][]byte, error)
- func (kv *EmbedEtcdKV) MultiRemove(keys []string) error
- func (kv *EmbedEtcdKV) MultiSave(kvs map[string]string) error
- func (kv *EmbedEtcdKV) MultiSaveAndRemove(saves map[string]string, removals []string, preds ...predicates.Predicate) error
- func (kv *EmbedEtcdKV) MultiSaveAndRemoveWithPrefix(saves map[string]string, removals []string, preds ...predicates.Predicate) error
- func (kv *EmbedEtcdKV) MultiSaveBytes(kvs map[string][]byte) error
- func (kv *EmbedEtcdKV) MultiSaveBytesAndRemove(saves map[string][]byte, removals []string) error
- func (kv *EmbedEtcdKV) MultiSaveBytesAndRemoveWithPrefix(saves map[string][]byte, removals []string) error
- func (kv *EmbedEtcdKV) Remove(key string) error
- func (kv *EmbedEtcdKV) RemoveWithPrefix(prefix string) error
- func (kv *EmbedEtcdKV) Save(key, value string) error
- func (kv *EmbedEtcdKV) SaveBytes(key string, value []byte) error
- func (kv *EmbedEtcdKV) SaveBytesWithLease(key string, value []byte, id clientv3.LeaseID) error
- func (kv *EmbedEtcdKV) WalkWithPrefix(prefix string, paginationSize int, fn func([]byte, []byte) error) error
- func (kv *EmbedEtcdKV) Watch(key string) clientv3.WatchChan
- func (kv *EmbedEtcdKV) WatchWithPrefix(key string) clientv3.WatchChan
- func (kv *EmbedEtcdKV) WatchWithRevision(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(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) 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 ¶
LoadBytesWithPrefix2 returns all the keys and values with versions by the given key prefix
func (*EmbedEtcdKV) LoadBytesWithRevision ¶
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 ¶
SaveBytesWithLease is a function to put value in etcd with etcd lease options.
func (*EmbedEtcdKV) WalkWithPrefix ¶
func (*EmbedEtcdKV) WatchWithPrefix ¶
func (kv *EmbedEtcdKV) WatchWithPrefix(key string) clientv3.WatchChan
func (*EmbedEtcdKV) WatchWithRevision ¶
func (kv *EmbedEtcdKV) WatchWithRevision(key string, revision int64) clientv3.WatchChan