From bbdd1dbef9f8966d95b6730649fcf6043a9dfe7c Mon Sep 17 00:00:00 2001 From: shaoyue Date: Tue, 30 Nov 2021 16:58:14 +0800 Subject: [PATCH] [skip ci] Add comment for etcd_kv.go (#12449) Signed-off-by: shaoyue.chen --- internal/kv/etcd/etcd_kv.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/kv/etcd/etcd_kv.go b/internal/kv/etcd/etcd_kv.go index e3c92a1662..2637222df4 100644 --- a/internal/kv/etcd/etcd_kv.go +++ b/internal/kv/etcd/etcd_kv.go @@ -308,6 +308,7 @@ func (kv *EtcdKV) WatchWithPrefix(key string) clientv3.WatchChan { return rch } +// WatchWithRevision starts watching a key with revision, returns a watch channel. func (kv *EtcdKV) WatchWithRevision(key string, revision int64) clientv3.WatchChan { start := time.Now() key = path.Join(kv.rootPath, key) @@ -316,6 +317,7 @@ func (kv *EtcdKV) WatchWithRevision(key string, revision int64) clientv3.WatchCh return rch } +// MultiRemoveWithPrefix removes the keys with given prefix. func (kv *EtcdKV) MultiRemoveWithPrefix(keys []string) error { start := time.Now() ops := make([]clientv3.Op, 0, len(keys)) @@ -331,6 +333,7 @@ func (kv *EtcdKV) MultiRemoveWithPrefix(keys []string) error { return err } +// MultiSaveAndRemoveWithPrefix saves kv in @saves and removes the keys with given prefix in @removals. func (kv *EtcdKV) MultiSaveAndRemoveWithPrefix(saves map[string]string, removals []string) error { start := time.Now() ops := make([]clientv3.Op, 0, len(saves)) @@ -414,6 +417,7 @@ func (kv *EtcdKV) CompareVersionAndSwap(key string, version int64, target string return nil } +// CheckElapseAndWarn checks the elapsed time and warns if it is too long. func CheckElapseAndWarn(start time.Time, message string) bool { elapsed := time.Since(start) if elapsed.Milliseconds() > 2000 {