*: Add progress notify request watch request
This commit is contained in:
@ -101,27 +101,33 @@ func watchInteractiveFunc(cmd *cobra.Command, osArgs []string, envKey, envRange
|
||||
l = strings.TrimSuffix(l, "\n")
|
||||
|
||||
args := argify(l)
|
||||
if len(args) < 2 && envKey == "" {
|
||||
fmt.Fprintf(os.Stderr, "Invalid command %s (command type or key is not provided)\n", l)
|
||||
continue
|
||||
}
|
||||
switch args[0] {
|
||||
case "watch":
|
||||
if len(args) < 2 && envKey == "" {
|
||||
fmt.Fprintf(os.Stderr, "Invalid command %s (command type or key is not provided)\n", l)
|
||||
continue
|
||||
}
|
||||
watchArgs, execArgs, perr := parseWatchArgs(osArgs, args, envKey, envRange, true)
|
||||
if perr != nil {
|
||||
ExitWithError(ExitBadArgs, perr)
|
||||
}
|
||||
|
||||
if args[0] != "watch" {
|
||||
ch, err := getWatchChan(c, watchArgs)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Invalid command %s (%v)\n", l, err)
|
||||
continue
|
||||
}
|
||||
go printWatchCh(c, ch, execArgs)
|
||||
case "progress":
|
||||
err := c.RequestProgress(clientv3.WithRequireLeader(context.Background()))
|
||||
if err != nil {
|
||||
ExitWithError(ExitError, err)
|
||||
}
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "Invalid command %s (only support watch)\n", l)
|
||||
continue
|
||||
}
|
||||
|
||||
watchArgs, execArgs, perr := parseWatchArgs(osArgs, args, envKey, envRange, true)
|
||||
if perr != nil {
|
||||
ExitWithError(ExitBadArgs, perr)
|
||||
}
|
||||
|
||||
ch, err := getWatchChan(c, watchArgs)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Invalid command %s (%v)\n", l, err)
|
||||
continue
|
||||
}
|
||||
go printWatchCh(c, ch, execArgs)
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,6 +158,9 @@ func printWatchCh(c *clientv3.Client, ch clientv3.WatchChan, execArgs []string)
|
||||
if resp.Canceled {
|
||||
fmt.Fprintf(os.Stderr, "watch was canceled (%v)\n", resp.Err())
|
||||
}
|
||||
if resp.IsProgressNotify() {
|
||||
fmt.Fprintf(os.Stdout, "progress notify: %d\n", resp.Header.Revision)
|
||||
}
|
||||
display.Watch(resp)
|
||||
|
||||
if len(execArgs) > 0 {
|
||||
|
Reference in New Issue
Block a user