From 04983dc00fe9ab8d304511b17b97567ab6f04dae Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Sun, 19 Jan 2020 15:21:51 -0800 Subject: [PATCH] [ci skip] Clarify terminology around 'state' and 'queue' --- tools/asynqmon/cmd/del.go | 2 +- tools/asynqmon/cmd/delall.go | 12 ++++++------ tools/asynqmon/cmd/enq.go | 2 +- tools/asynqmon/cmd/enqall.go | 12 ++++++------ tools/asynqmon/cmd/kill.go | 6 +++--- tools/asynqmon/cmd/killall.go | 12 ++++++------ tools/asynqmon/cmd/ls.go | 4 ++-- tools/asynqmon/cmd/root.go | 4 ++-- tools/asynqmon/cmd/stats.go | 15 ++++++++++----- 9 files changed, 37 insertions(+), 32 deletions(-) diff --git a/tools/asynqmon/cmd/del.go b/tools/asynqmon/cmd/del.go index 28d2169..913a29e 100644 --- a/tools/asynqmon/cmd/del.go +++ b/tools/asynqmon/cmd/del.go @@ -21,7 +21,7 @@ var delCmd = &cobra.Command{ Long: `Del (asynqmon del) will delete a task given an identifier. The command takes one argument which specifies the task to delete. -The task should be in either scheduled, retry or dead queue. +The task should be in either scheduled, retry or dead state. Identifier for a task should be obtained by running "asynqmon ls" command. Example: asynqmon enq d:1575732274:bnogo8gt6toe23vhef0g`, diff --git a/tools/asynqmon/cmd/delall.go b/tools/asynqmon/cmd/delall.go index ce1b8fc..95f426a 100644 --- a/tools/asynqmon/cmd/delall.go +++ b/tools/asynqmon/cmd/delall.go @@ -18,13 +18,13 @@ var delallValidArgs = []string{"scheduled", "retry", "dead"} // delallCmd represents the delall command var delallCmd = &cobra.Command{ - Use: "delall [queue name]", - Short: "Deletes all tasks from the specified queue", - Long: `Delall (asynqmon delall) will delete all tasks from the specified queue. + Use: "delall [state]", + Short: "Deletes all tasks from the specified state", + Long: `Delall (asynqmon delall) will delete all tasks in the specified state. The argument should be one of "scheduled", "retry", or "dead". -Example: asynqmon delall dead -> Deletes all tasks from the dead queue`, +Example: asynqmon delall dead -> Deletes all dead tasks`, ValidArgs: delallValidArgs, Args: cobra.ExactValidArgs(1), Run: delall, @@ -60,12 +60,12 @@ func delall(cmd *cobra.Command, args []string) { case "dead": err = r.DeleteAllDeadTasks() default: - fmt.Printf("error: `asynqmon delall [queue name]` only accepts %v as the argument.\n", delallValidArgs) + fmt.Printf("error: `asynqmon delall [state]` only accepts %v as the argument.\n", delallValidArgs) os.Exit(1) } if err != nil { fmt.Println(err) os.Exit(1) } - fmt.Printf("Deleted all tasks from %q queue\n", args[0]) + fmt.Printf("Deleted all tasks in %q state\n", args[0]) } diff --git a/tools/asynqmon/cmd/enq.go b/tools/asynqmon/cmd/enq.go index 31831b1..f47d9c6 100644 --- a/tools/asynqmon/cmd/enq.go +++ b/tools/asynqmon/cmd/enq.go @@ -21,7 +21,7 @@ var enqCmd = &cobra.Command{ Long: `Enq (asynqmon enq) will enqueue a task given an identifier. The command takes one argument which specifies the task to enqueue. -The task should be in either scheduled, retry or dead queue. +The task should be in either scheduled, retry or dead state. Identifier for a task should be obtained by running "asynqmon ls" command. The task enqueued by this command will be processed as soon as the task diff --git a/tools/asynqmon/cmd/enqall.go b/tools/asynqmon/cmd/enqall.go index e5e1ab5..27099c7 100644 --- a/tools/asynqmon/cmd/enqall.go +++ b/tools/asynqmon/cmd/enqall.go @@ -18,16 +18,16 @@ var enqallValidArgs = []string{"scheduled", "retry", "dead"} // enqallCmd represents the enqall command var enqallCmd = &cobra.Command{ - Use: "enqall [queue name]", - Short: "Enqueues all tasks from the specified queue", - Long: `Enqall (asynqmon enqall) will enqueue all tasks from the specified queue. + Use: "enqall [state]", + Short: "Enqueues all tasks in the specified state", + Long: `Enqall (asynqmon enqall) will enqueue all tasks in the specified state. The argument should be one of "scheduled", "retry", or "dead". The tasks enqueued by this command will be processed as soon as it gets dequeued by a processor. -Example: asynqmon enqall dead -> Enqueues all tasks from the dead queue`, +Example: asynqmon enqall dead -> Enqueues all dead tasks`, ValidArgs: enqallValidArgs, Args: cobra.ExactValidArgs(1), Run: enqall, @@ -64,12 +64,12 @@ func enqall(cmd *cobra.Command, args []string) { case "dead": n, err = r.EnqueueAllDeadTasks() default: - fmt.Printf("error: `asynqmon enqall [queue name]` only accepts %v as the argument.\n", enqallValidArgs) + fmt.Printf("error: `asynqmon enqall [state]` only accepts %v as the argument.\n", enqallValidArgs) os.Exit(1) } if err != nil { fmt.Println(err) os.Exit(1) } - fmt.Printf("Enqueued %d tasks from %q queue\n", n, args[0]) + fmt.Printf("Enqueued %d tasks in %q state\n", n, args[0]) } diff --git a/tools/asynqmon/cmd/kill.go b/tools/asynqmon/cmd/kill.go index 80986bb..6351562 100644 --- a/tools/asynqmon/cmd/kill.go +++ b/tools/asynqmon/cmd/kill.go @@ -17,11 +17,11 @@ import ( // killCmd represents the kill command var killCmd = &cobra.Command{ Use: "kill [task id]", - Short: "Sends a task to dead queue given an identifier", - Long: `Kill (asynqmon kill) will send a task to dead queue given an identifier. + Short: "Kills a task given an identifier", + Long: `Kill (asynqmon kill) will put a task in dead state given an identifier. The command takes one argument which specifies the task to kill. -The task should be in either scheduled or retry queue. +The task should be in either scheduled or retry state. Identifier for a task should be obtained by running "asynqmon ls" command. Example: asynqmon kill r:1575732274:bnogo8gt6toe23vhef0g`, diff --git a/tools/asynqmon/cmd/killall.go b/tools/asynqmon/cmd/killall.go index 00c2d3d..e1255d0 100644 --- a/tools/asynqmon/cmd/killall.go +++ b/tools/asynqmon/cmd/killall.go @@ -18,13 +18,13 @@ var killallValidArgs = []string{"scheduled", "retry"} // killallCmd represents the killall command var killallCmd = &cobra.Command{ - Use: "killall [queue name]", - Short: "Sends all tasks to dead queue from the specified queue", - Long: `Killall (asynqmon killall) will moves all tasks from the specified queue to dead queue. + Use: "killall [state]", + Short: "Update all tasks to dead state from the specified state", + Long: `Killall (asynqmon killall) will update all tasks from the specified state to dead state. The argument should be either "scheduled" or "retry". -Example: asynqmon killall retry -> Moves all tasks from retry queue to dead queue`, +Example: asynqmon killall retry -> Update all retry tasks to dead tasks`, ValidArgs: killallValidArgs, Args: cobra.ExactValidArgs(1), Run: killall, @@ -59,12 +59,12 @@ func killall(cmd *cobra.Command, args []string) { case "retry": n, err = r.KillAllRetryTasks() default: - fmt.Printf("error: `asynqmon killall [queue name]` only accepts %v as the argument.\n", killallValidArgs) + fmt.Printf("error: `asynqmon killall [state]` only accepts %v as the argument.\n", killallValidArgs) os.Exit(1) } if err != nil { fmt.Println(err) os.Exit(1) } - fmt.Printf("Sent %d tasks to \"dead\" queue from %q queue\n", n, args[0]) + fmt.Printf("Successfully updated %d tasks to \"dead\" state\n", n) } diff --git a/tools/asynqmon/cmd/ls.go b/tools/asynqmon/cmd/ls.go index 7070dee..3250368 100644 --- a/tools/asynqmon/cmd/ls.go +++ b/tools/asynqmon/cmd/ls.go @@ -24,7 +24,7 @@ var lsValidArgs = []string{"enqueued", "inprogress", "scheduled", "retry", "dead // lsCmd represents the ls command var lsCmd = &cobra.Command{ - Use: "ls [task state]", + Use: "ls [state]", Short: "Lists tasks in the specified state", Long: `Ls (asynqmon ls) will list all tasks in the specified state in a table format. @@ -77,7 +77,7 @@ func ls(cmd *cobra.Command, args []string) { case "dead": listDead(r) default: - fmt.Printf("error: `asynqmon ls [task state]` only accepts %v as the argument.\n", lsValidArgs) + fmt.Printf("error: `asynqmon ls [state]` only accepts %v as the argument.\n", lsValidArgs) os.Exit(1) } } diff --git a/tools/asynqmon/cmd/root.go b/tools/asynqmon/cmd/root.go index 1f19c3c..95af88d 100644 --- a/tools/asynqmon/cmd/root.go +++ b/tools/asynqmon/cmd/root.go @@ -25,9 +25,9 @@ var password string var rootCmd = &cobra.Command{ Use: "asynqmon", Short: "A monitoring tool for asynq queues", - Long: `Asynqmon is a CLI tool to inspect and monitor queues managed by asynq package. + Long: `Asynqmon is a CLI tool to inspect tasks and queues managed by asynq package. -Asynqmon has a few commands to query and mutate the current state of the queues. +Use commands to query and mutate the current state of tasks and queues. Monitoring commands such as "stats" and "ls" can be used in conjunction with the "watch" command to continuously run the command at a certain interval. diff --git a/tools/asynqmon/cmd/stats.go b/tools/asynqmon/cmd/stats.go index 6ceb0ea..7c1e5df 100644 --- a/tools/asynqmon/cmd/stats.go +++ b/tools/asynqmon/cmd/stats.go @@ -21,14 +21,19 @@ import ( // statsCmd represents the stats command var statsCmd = &cobra.Command{ Use: "stats", - Short: "Shows current state of the queues", - Long: `Stats (aysnqmon stats) will show the number of tasks in each queue at that instant. -It also displays basic information about the running redis instance. + Short: "Shows current state of the tasks and queues", + Long: `Stats (aysnqmon stats) will show the overview of tasks and queues at that instant. -To monitor the queues continuously, it's recommended that you run this +Specifically, the command shows the following: +* Number of tasks in each state +* Number of tasks in each queue +* Aggregate data for the current day +* Basic information about the running redis instance + +To monitor the tasks continuously, it's recommended that you run this command in conjunction with the watch command. -Example: watch -n 5 asynqmon stats`, +Example: watch -n 3 asynqmon stats -> Shows current state of tasks every three seconds`, Args: cobra.NoArgs, Run: stats, }