mirror of
https://github.com/hibiken/asynq.git
synced 2025-10-26 11:16:12 +08:00
Add RedisInfo method to RDB
This commit is contained in:
@@ -3,6 +3,7 @@ package rdb
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-redis/redis/v7"
|
||||
@@ -93,6 +94,23 @@ func (r *RDB) CurrentStats() (*Stats, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// RedisInfo returns a map of redis info.
|
||||
func (r *RDB) RedisInfo() (map[string]string, error) {
|
||||
res, err := r.client.Info().Result()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
info := make(map[string]string)
|
||||
lines := strings.Split(res, "\r\n")
|
||||
for _, l := range lines {
|
||||
kv := strings.Split(l, ":")
|
||||
if len(kv) == 2 {
|
||||
info[kv[0]] = kv[1]
|
||||
}
|
||||
}
|
||||
return info, nil
|
||||
}
|
||||
|
||||
// ListEnqueued returns all enqueued tasks that are ready to be processed.
|
||||
func (r *RDB) ListEnqueued() ([]*EnqueuedTask, error) {
|
||||
data, err := r.client.LRange(base.DefaultQueue, 0, -1).Result()
|
||||
|
||||
Reference in New Issue
Block a user