Merge pull request #11462 from jingyih/etcdctl_support_watch_progress_notify

etcdctl: support progress notify option
This commit is contained in:
Sahdev Zala 2020-01-14 10:07:37 -05:00 committed by GitHub
commit 908f45ebe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -95,6 +95,7 @@ Note that any `etcd_debugging_*` metrics are experimental and subject to change.
### etcdctl v3
- Fix [`etcdctl member add`](https://github.com/etcd-io/etcd/pull/11194) command to prevent potential timeout.
- Add [`etcdctl watch --progress-notify`](https://github.com/etcd-io/etcd/pull/11462) flag.
### gRPC gateway

View File

@ -40,6 +40,7 @@ var (
watchPrefix bool
watchInteractive bool
watchPrevKey bool
progressNotify bool
)
// NewWatchCommand returns the cobra command for "watch".
@ -54,6 +55,7 @@ func NewWatchCommand() *cobra.Command {
cmd.Flags().BoolVar(&watchPrefix, "prefix", false, "Watch on a prefix if prefix is set")
cmd.Flags().Int64Var(&watchRev, "rev", 0, "Revision to start watching")
cmd.Flags().BoolVar(&watchPrevKey, "prev-kv", false, "get the previous key-value pair before the event happens")
cmd.Flags().BoolVar(&progressNotify, "progress-notify", false, "get periodic watch progress notification from server")
return cmd
}
@ -154,6 +156,9 @@ func getWatchChan(c *clientv3.Client, args []string) (clientv3.WatchChan, error)
if watchPrevKey {
opts = append(opts, clientv3.WithPrevKV())
}
if progressNotify {
opts = append(opts, clientv3.WithProgressNotify())
}
return c.Watch(clientv3.WithRequireLeader(context.Background()), key, opts...), nil
}