@@ -84,25 +84,33 @@ func main() {
8484 os .Exit (1 )
8585 }
8686
87- redisClient := redis . NewClient ( & redis.Options {
87+ redisOptions := redis.Options {
8888 Addr : fmt .Sprintf ("%s:%s" , cfg .RedisHost , cfg .RedisPort ),
8989 Password : cfg .RedisPassword ,
9090 DB : cfg .RedisDB ,
9191 TLSConfig : redisTLSConfig ,
92- })
92+ }
93+ if cfg .RedisUsername != "" {
94+ redisOptions .Username = cfg .RedisUsername
95+ }
96+ redisClient := redis .NewClient (& redisOptions )
9397
9498 if _ , err := redisClient .Ping (ctx ).Result (); err != nil {
9599 s .Logger ().Error ("failed to connect to redis" , "redis" , redisClient .String (), "error" , err )
96100 metricRecorder .RecordServiceStartupAttempt (ctx , false )
97101 os .Exit (1 )
98102 }
99103
100- redisStreamClient := redis . NewClient ( & redis.Options {
104+ redisStreamOptions := redis.Options {
101105 Addr : fmt .Sprintf ("%s:%s" , cfg .RedisHost , cfg .RedisPort ),
102106 Password : cfg .RedisPassword ,
103107 DB : cfg .RedisStreamDB ,
104108 TLSConfig : redisTLSConfig ,
105- })
109+ }
110+ if cfg .RedisUsername != "" {
111+ redisStreamOptions .Username = cfg .RedisUsername
112+ }
113+ redisStreamClient := redis .NewClient (& redisStreamOptions )
106114
107115 if _ , err := redisStreamClient .Ping (ctx ).Result (); err != nil {
108116 s .Logger ().Error ("failed to connect to redis stream" , "redisStream" , redisStreamClient .String (), "error" , err )
0 commit comments