From f90b2cde7172a78a7a0aba34802b3430ea129fdf Mon Sep 17 00:00:00 2001 From: ChihSeanHsu Date: Mon, 10 Oct 2022 15:50:48 +0800 Subject: [PATCH] chore: add redis username --- cmd/asynqmon/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/asynqmon/main.go b/cmd/asynqmon/main.go index efc0f1d..9830759 100644 --- a/cmd/asynqmon/main.go +++ b/cmd/asynqmon/main.go @@ -28,6 +28,7 @@ type Config struct { // Redis connection options RedisAddr string RedisDB int + RedisUsername string RedisPassword string RedisTLS string RedisURL string @@ -62,6 +63,7 @@ func parseFlags(progname string, args []string) (cfg *Config, output string, err flags.IntVar(&conf.Port, "port", getEnvOrDefaultInt("PORT", 8080), "port number to use for web ui server") flags.StringVar(&conf.RedisAddr, "redis-addr", getEnvDefaultString("REDIS_ADDR", "127.0.0.1:6379"), "address of redis server to connect to") flags.IntVar(&conf.RedisDB, "redis-db", getEnvOrDefaultInt("REDIS_DB", 0), "redis database number") + flags.StringVar(&conf.RedisUsername, "redis-username", getEnvDefaultString("REDIS_USERNAME", ""), "username to use when connecting to redis server") flags.StringVar(&conf.RedisPassword, "redis-password", getEnvDefaultString("REDIS_PASSWORD", ""), "password to use when connecting to redis server") flags.StringVar(&conf.RedisTLS, "redis-tls", getEnvDefaultString("REDIS_TLS", ""), "server name for TLS validation used when connecting to redis server") flags.StringVar(&conf.RedisURL, "redis-url", getEnvDefaultString("REDIS_URL", ""), "URL to redis server") @@ -96,6 +98,7 @@ func makeRedisConnOpt(cfg *Config) (asynq.RedisConnOpt, error) { if len(cfg.RedisClusterNodes) > 0 { return asynq.RedisClusterClientOpt{ Addrs: strings.Split(cfg.RedisClusterNodes, ","), + Username: cfg.RedisUsername, Password: cfg.RedisPassword, TLSConfig: makeTLSConfig(cfg), }, nil @@ -123,6 +126,7 @@ func makeRedisConnOpt(cfg *Config) (asynq.RedisConnOpt, error) { } else { connOpt.Addr = cfg.RedisAddr connOpt.DB = cfg.RedisDB + connOpt.Username = cfg.RedisUsername connOpt.Password = cfg.RedisPassword } if connOpt.TLSConfig == nil {