etcdctl: support progress notify option

Add support for progress notify option to etcdctl watch command.
This commit is contained in:
Jingyi Hu 2019-12-17 14:16:42 -08:00
parent 5770a6d286
commit c0de070527

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
}