mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-26 07:42:17 +08:00
(cli): Update stats command to print the number of aggregating tasks
This commit is contained in:
parent
578321f226
commit
451be7e50f
@ -59,15 +59,16 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AggregateStats struct {
|
type AggregateStats struct {
|
||||||
Active int `json:"active"`
|
Active int `json:"active"`
|
||||||
Pending int `json:"pending"`
|
Pending int `json:"pending"`
|
||||||
Scheduled int `json:"scheduled"`
|
Aggregating int `json:"aggregating"`
|
||||||
Retry int `json:"retry"`
|
Scheduled int `json:"scheduled"`
|
||||||
Archived int `json:"archived"`
|
Retry int `json:"retry"`
|
||||||
Completed int `json:"completed"`
|
Archived int `json:"archived"`
|
||||||
Processed int `json:"processed"`
|
Completed int `json:"completed"`
|
||||||
Failed int `json:"failed"`
|
Processed int `json:"processed"`
|
||||||
Timestamp time.Time `json:"timestamp"`
|
Failed int `json:"failed"`
|
||||||
|
Timestamp time.Time `json:"timestamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FullStats struct {
|
type FullStats struct {
|
||||||
@ -95,6 +96,7 @@ func stats(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
aggStats.Active += s.Active
|
aggStats.Active += s.Active
|
||||||
aggStats.Pending += s.Pending
|
aggStats.Pending += s.Pending
|
||||||
|
aggStats.Aggregating += s.Aggregating
|
||||||
aggStats.Scheduled += s.Scheduled
|
aggStats.Scheduled += s.Scheduled
|
||||||
aggStats.Retry += s.Retry
|
aggStats.Retry += s.Retry
|
||||||
aggStats.Archived += s.Archived
|
aggStats.Archived += s.Archived
|
||||||
@ -155,13 +157,13 @@ func stats(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printStatsByState(s *AggregateStats) {
|
func printStatsByState(s *AggregateStats) {
|
||||||
format := strings.Repeat("%v\t", 6) + "\n"
|
format := strings.Repeat("%v\t", 7) + "\n"
|
||||||
tw := new(tabwriter.Writer).Init(os.Stdout, 0, 8, 2, ' ', 0)
|
tw := new(tabwriter.Writer).Init(os.Stdout, 0, 8, 2, ' ', 0)
|
||||||
fmt.Fprintf(tw, format, "active", "pending", "scheduled", "retry", "archived", "completed")
|
fmt.Fprintf(tw, format, "active", "pending", "aggregating", "scheduled", "retry", "archived", "completed")
|
||||||
width := maxInt(9 /* defaultWidth */, maxWidthOf(s.Active, s.Pending, s.Scheduled, s.Retry, s.Archived, s.Completed)) // length of widest column
|
width := maxInt(9 /* defaultWidth */, maxWidthOf(s.Active, s.Pending, s.Aggregating, s.Scheduled, s.Retry, s.Archived, s.Completed)) // length of widest column
|
||||||
sep := strings.Repeat("-", width)
|
sep := strings.Repeat("-", width)
|
||||||
fmt.Fprintf(tw, format, sep, sep, sep, sep, sep, sep)
|
fmt.Fprintf(tw, format, sep, sep, sep, sep, sep, sep, sep)
|
||||||
fmt.Fprintf(tw, format, s.Active, s.Pending, s.Scheduled, s.Retry, s.Archived, s.Completed)
|
fmt.Fprintf(tw, format, s.Active, s.Pending, s.Aggregating, s.Scheduled, s.Retry, s.Archived, s.Completed)
|
||||||
tw.Flush()
|
tw.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user