From c0de0705272ea1718819946b54c2b44109b88edb Mon Sep 17 00:00:00 2001 From: Jingyi Hu Date: Tue, 17 Dec 2019 14:16:42 -0800 Subject: [PATCH] etcdctl: support progress notify option Add support for progress notify option to etcdctl watch command. --- etcdctl/ctlv3/command/watch_command.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/etcdctl/ctlv3/command/watch_command.go b/etcdctl/ctlv3/command/watch_command.go index ce8425cbe..c75ce20f0 100644 --- a/etcdctl/ctlv3/command/watch_command.go +++ b/etcdctl/ctlv3/command/watch_command.go @@ -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 }