mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-27 00:02:19 +08:00
Fix CLI build
This commit is contained in:
parent
14c381dc40
commit
430b01c9aa
@ -11,7 +11,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq/inspeq"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ func cronHistory(cmd *cobra.Command, args []string) {
|
|||||||
fmt.Printf("Entry: %s\n\n", entryID)
|
fmt.Printf("Entry: %s\n\n", entryID)
|
||||||
|
|
||||||
events, err := inspector.ListSchedulerEnqueueEvents(
|
events, err := inspector.ListSchedulerEnqueueEvents(
|
||||||
entryID, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
entryID, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error: %v\n", err)
|
fmt.Printf("error: %v\n", err)
|
||||||
continue
|
continue
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq/inspeq"
|
||||||
"github.com/hibiken/asynq/internal/rdb"
|
"github.com/hibiken/asynq/internal/rdb"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -82,7 +82,7 @@ func queueList(cmd *cobra.Command, args []string) {
|
|||||||
type queueInfo struct {
|
type queueInfo struct {
|
||||||
name string
|
name string
|
||||||
keyslot int64
|
keyslot int64
|
||||||
nodes []asynq.ClusterNode
|
nodes []inspeq.ClusterNode
|
||||||
}
|
}
|
||||||
inspector := createInspector()
|
inspector := createInspector()
|
||||||
queues, err := inspector.Queues()
|
queues, err := inspector.Queues()
|
||||||
@ -141,7 +141,7 @@ func queueInspect(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func printQueueStats(s *asynq.QueueStats) {
|
func printQueueStats(s *inspeq.QueueStats) {
|
||||||
bold := color.New(color.Bold)
|
bold := color.New(color.Bold)
|
||||||
bold.Println("Queue Info")
|
bold.Println("Queue Info")
|
||||||
fmt.Printf("Name: %s\n", s.Queue)
|
fmt.Printf("Name: %s\n", s.Queue)
|
||||||
@ -191,7 +191,7 @@ func queueHistory(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func printDailyStats(stats []*asynq.DailyStats) {
|
func printDailyStats(stats []*inspeq.DailyStats) {
|
||||||
printTable(
|
printTable(
|
||||||
[]string{"date (UTC)", "processed", "failed", "error rate"},
|
[]string{"date (UTC)", "processed", "failed", "error rate"},
|
||||||
func(w io.Writer, tmpl string) {
|
func(w io.Writer, tmpl string) {
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-redis/redis/v7"
|
"github.com/go-redis/redis/v7"
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq"
|
||||||
|
"github.com/hibiken/asynq/inspeq"
|
||||||
"github.com/hibiken/asynq/internal/base"
|
"github.com/hibiken/asynq/internal/base"
|
||||||
"github.com/hibiken/asynq/internal/rdb"
|
"github.com/hibiken/asynq/internal/rdb"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -135,7 +136,7 @@ func createRDB() *rdb.RDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// createRDB creates a Inspector instance using flag values and returns it.
|
// createRDB creates a Inspector instance using flag values and returns it.
|
||||||
func createInspector() *asynq.Inspector {
|
func createInspector() *inspeq.Inspector {
|
||||||
var connOpt asynq.RedisConnOpt
|
var connOpt asynq.RedisConnOpt
|
||||||
if useRedisCluster {
|
if useRedisCluster {
|
||||||
addrs := strings.Split(viper.GetString("cluster_addrs"), ",")
|
addrs := strings.Split(viper.GetString("cluster_addrs"), ",")
|
||||||
@ -152,7 +153,7 @@ func createInspector() *asynq.Inspector {
|
|||||||
TLSConfig: getTLSConfig(),
|
TLSConfig: getTLSConfig(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return asynq.NewInspector(connOpt)
|
return inspeq.New(connOpt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTLSConfig() *tls.Config {
|
func getTLSConfig() *tls.Config {
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq/inspeq"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ func taskList(cmd *cobra.Command, args []string) {
|
|||||||
|
|
||||||
func listActiveTasks(qname string, pageNum, pageSize int) {
|
func listActiveTasks(qname string, pageNum, pageSize int) {
|
||||||
i := createInspector()
|
i := createInspector()
|
||||||
tasks, err := i.ListActiveTasks(qname, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
tasks, err := i.ListActiveTasks(qname, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -204,7 +204,7 @@ func listActiveTasks(qname string, pageNum, pageSize int) {
|
|||||||
|
|
||||||
func listPendingTasks(qname string, pageNum, pageSize int) {
|
func listPendingTasks(qname string, pageNum, pageSize int) {
|
||||||
i := createInspector()
|
i := createInspector()
|
||||||
tasks, err := i.ListPendingTasks(qname, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
tasks, err := i.ListPendingTasks(qname, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -225,7 +225,7 @@ func listPendingTasks(qname string, pageNum, pageSize int) {
|
|||||||
|
|
||||||
func listScheduledTasks(qname string, pageNum, pageSize int) {
|
func listScheduledTasks(qname string, pageNum, pageSize int) {
|
||||||
i := createInspector()
|
i := createInspector()
|
||||||
tasks, err := i.ListScheduledTasks(qname, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
tasks, err := i.ListScheduledTasks(qname, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -248,7 +248,7 @@ func listScheduledTasks(qname string, pageNum, pageSize int) {
|
|||||||
|
|
||||||
func listRetryTasks(qname string, pageNum, pageSize int) {
|
func listRetryTasks(qname string, pageNum, pageSize int) {
|
||||||
i := createInspector()
|
i := createInspector()
|
||||||
tasks, err := i.ListRetryTasks(qname, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
tasks, err := i.ListRetryTasks(qname, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -267,7 +267,7 @@ func listRetryTasks(qname string, pageNum, pageSize int) {
|
|||||||
} else {
|
} else {
|
||||||
nextRetry = "right now"
|
nextRetry = "right now"
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, tmpl, t.Key(), t.Type, t.Payload, nextRetry, t.ErrorMsg, t.Retried, t.MaxRetry)
|
fmt.Fprintf(w, tmpl, t.Key(), t.Type, t.Payload, nextRetry, t.LastError, t.Retried, t.MaxRetry)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -275,7 +275,7 @@ func listRetryTasks(qname string, pageNum, pageSize int) {
|
|||||||
|
|
||||||
func listArchivedTasks(qname string, pageNum, pageSize int) {
|
func listArchivedTasks(qname string, pageNum, pageSize int) {
|
||||||
i := createInspector()
|
i := createInspector()
|
||||||
tasks, err := i.ListArchivedTasks(qname, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
tasks, err := i.ListArchivedTasks(qname, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -288,7 +288,7 @@ func listArchivedTasks(qname string, pageNum, pageSize int) {
|
|||||||
[]string{"Key", "Type", "Payload", "Last Failed", "Last Error"},
|
[]string{"Key", "Type", "Payload", "Last Failed", "Last Error"},
|
||||||
func(w io.Writer, tmpl string) {
|
func(w io.Writer, tmpl string) {
|
||||||
for _, t := range tasks {
|
for _, t := range tasks {
|
||||||
fmt.Fprintf(w, tmpl, t.Key(), t.Type, t.Payload, t.LastFailedAt, t.ErrorMsg)
|
fmt.Fprintf(w, tmpl, t.Key(), t.Type, t.Payload, t.LastFailedAt, t.LastError)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user