etcd: add WatchKey function

This commit is contained in:
Simone Gotti 2019-05-15 09:41:06 +02:00
parent b95fb98f3c
commit 846567b96a
1 changed files with 8 additions and 0 deletions

View File

@ -301,6 +301,14 @@ func (s *Store) AtomicDelete(ctx context.Context, key string, revision int64) (*
return tresp, nil return tresp, nil
} }
func (s *Store) WatchKey(ctx context.Context, prefix string, revision int64) etcdclientv3.WatchChan {
etcdv3Options := []etcdclientv3.OpOption{}
if revision != 0 {
etcdv3Options = append(etcdv3Options, etcdclientv3.WithRev(revision))
}
return s.c.Watch(ctx, prefix, etcdv3Options...)
}
func (s *Store) Watch(ctx context.Context, prefix string, revision int64) etcdclientv3.WatchChan { func (s *Store) Watch(ctx context.Context, prefix string, revision int64) etcdclientv3.WatchChan {
etcdv3Options := []etcdclientv3.OpOption{clientv3.WithPrefix()} etcdv3Options := []etcdclientv3.OpOption{clientv3.WithPrefix()}
if revision != 0 { if revision != 0 {