2
0
mirror of https://github.com/hibiken/asynq.git synced 2025-08-28 08:21:53 +08:00

Extract rdb to internal package

This commit is contained in:
Ken Hibino
2019-12-03 21:01:26 -08:00
parent 593f2b0482
commit d4e442d04f
17 changed files with 488 additions and 971 deletions

View File

@@ -9,19 +9,21 @@ import (
"text/tabwriter"
"time"
"github.com/hibiken/asynq"
"github.com/go-redis/redis/v7"
"github.com/hibiken/asynq/internal/rdb"
)
var pollInterval = flag.Duration("interval", 3*time.Second, "polling interval")
func main() {
inspector := asynq.NewInspector(&asynq.RedisConfig{
c := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
DB: 2,
})
r := rdb.NewClient(c)
for {
stats, err := inspector.CurrentStats()
stats, err := r.CurrentStats()
if err != nil {
log.Fatal(err)
}
@@ -31,7 +33,7 @@ func main() {
}
}
func printStats(s *asynq.Stats) {
func printStats(s *rdb.Stats) {
format := strings.Repeat("%v\t", 5) + "\n"
tw := new(tabwriter.Writer).Init(os.Stdout, 0, 8, 2, ' ', 0)
fmt.Fprintf(tw, format, "Enqueued", "InProgress", "Scheduled", "Retry", "Dead")