diff --git a/cmd/asynqmon/main.go b/cmd/asynqmon/main.go index 2053571..77e7623 100644 --- a/cmd/asynqmon/main.go +++ b/cmd/asynqmon/main.go @@ -98,8 +98,18 @@ func makeTLSConfig(cfg *Config) *tls.Config { } func makeRedisConnOpt(cfg *Config) (asynq.RedisConnOpt, error) { + cleanUpClusterNodes := func(clusterNodes string) string { + clusterNodes = strings.ReplaceAll(clusterNodes, "]", "") + clusterNodes = strings.ReplaceAll(clusterNodes, "[", "") + clusterNodes = strings.ReplaceAll(clusterNodes, "\"", "") + clusterNodes = strings.ReplaceAll(clusterNodes, " ", "") + clusterNodes = strings.ReplaceAll(clusterNodes, "\n", "") + return clusterNodes + } + // Connecting to redis-cluster if len(cfg.RedisClusterNodes) > 0 { + cfg.RedisClusterNodes = cleanUpClusterNodes(cfg.RedisClusterNodes) return asynq.RedisClusterClientOpt{ Addrs: strings.Split(cfg.RedisClusterNodes, ","), Password: cfg.RedisPassword, diff --git a/cmd/asynqmon/main_test.go b/cmd/asynqmon/main_test.go index b3c566f..6b3df5c 100644 --- a/cmd/asynqmon/main_test.go +++ b/cmd/asynqmon/main_test.go @@ -119,6 +119,17 @@ func TestMakeRedisConnOpt(t *testing.T) { "localhost:5000", "localhost:5001", "localhost:5002", "localhost:5003", "localhost:5004", "localhost:5005"}, }, }, + { + desc: "With cluster nodes array", + cfg: &Config{ + RedisClusterNodes: `["localhost:5000", "localhost:5001", "localhost:5002", +"localhost:5003", "localhost:5004", "localhost:5005"]`, + }, + want: asynq.RedisClusterClientOpt{ + Addrs: []string{ + "localhost:5000", "localhost:5001", "localhost:5002", "localhost:5003", "localhost:5004", "localhost:5005"}, + }, + }, } for _, tc := range tests {