2
0
mirror of https://github.com/hibiken/asynq.git synced 2025-08-19 15:08:55 +08:00

Display cluster info in stats command when --cluster flag is passed

This commit is contained in:
Ken Hibino
2020-09-07 12:55:32 -07:00
parent 818c2d6f35
commit c26b7469bd
2 changed files with 41 additions and 4 deletions

View File

@@ -222,8 +222,21 @@ func (r *RDB) RedisInfo() (map[string]string, error) {
if err != nil {
return nil, err
}
return parseInfo(res)
}
// RedisClusterInfo returns a map of redis cluster info.
func (r *RDB) RedisClusterInfo() (map[string]string, error) {
res, err := r.client.ClusterInfo().Result()
if err != nil {
return nil, err
}
return parseInfo(res)
}
func parseInfo(infoStr string) (map[string]string, error) {
info := make(map[string]string)
lines := strings.Split(res, "\r\n")
lines := strings.Split(infoStr, "\r\n")
for _, l := range lines {
kv := strings.Split(l, ":")
if len(kv) == 2 {