2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-27 16:13:40 +08:00

Add Username field to RedisConnOpt

This commit is contained in:
Ken Hibino 2020-09-08 05:51:05 -07:00
parent c26b7469bd
commit 6e294a7013

View File

@ -52,8 +52,12 @@ type RedisClientOpt struct {
// Redis server address in "host:port" format. // Redis server address in "host:port" format.
Addr string Addr string
// TODO: Add Username // Username to authenticate the current connection when Redis ACLs are used.
// Redis server password. // See: https://redis.io/commands/auth.
Username string
// Password to authenticate the current connection.
// See: https://redis.io/commands/auth.
Password string Password string
// Redis DB to select after connecting to a server. // Redis DB to select after connecting to a server.
@ -84,8 +88,12 @@ type RedisFailoverClientOpt struct {
// Redis sentinel password. // Redis sentinel password.
SentinelPassword string SentinelPassword string
// TODO: Add Username // Username to authenticate the current connection when Redis ACLs are used.
// Redis server password. // See: https://redis.io/commands/auth.
Username string
// Password to authenticate the current connection.
// See: https://redis.io/commands/auth.
Password string Password string
// Redis DB to select after connecting to a server. // Redis DB to select after connecting to a server.
@ -107,8 +115,12 @@ type RedisClusterClientOpt struct {
// A seed list of host:port addresses of cluster nodes. // A seed list of host:port addresses of cluster nodes.
Addrs []string Addrs []string
// TODO: Add Username // Username to authenticate the current connection when Redis ACLs are used.
// Redis server password. // See: https://redis.io/commands/auth.
Username string
// Password to authenticate the current connection.
// See: https://redis.io/commands/auth.
Password string Password string
// TLS Config used to connect to a server. // TLS Config used to connect to a server.
@ -198,6 +210,7 @@ func createRedisClient(r RedisConnOpt) redis.UniversalClient {
return redis.NewClient(&redis.Options{ return redis.NewClient(&redis.Options{
Network: r.Network, Network: r.Network,
Addr: r.Addr, Addr: r.Addr,
Username: r.Username,
Password: r.Password, Password: r.Password,
DB: r.DB, DB: r.DB,
PoolSize: r.PoolSize, PoolSize: r.PoolSize,
@ -207,6 +220,7 @@ func createRedisClient(r RedisConnOpt) redis.UniversalClient {
return redis.NewClient(&redis.Options{ return redis.NewClient(&redis.Options{
Network: r.Network, Network: r.Network,
Addr: r.Addr, Addr: r.Addr,
Username: r.Username,
Password: r.Password, Password: r.Password,
DB: r.DB, DB: r.DB,
PoolSize: r.PoolSize, PoolSize: r.PoolSize,
@ -217,6 +231,7 @@ func createRedisClient(r RedisConnOpt) redis.UniversalClient {
MasterName: r.MasterName, MasterName: r.MasterName,
SentinelAddrs: r.SentinelAddrs, SentinelAddrs: r.SentinelAddrs,
SentinelPassword: r.SentinelPassword, SentinelPassword: r.SentinelPassword,
Username: r.Username,
Password: r.Password, Password: r.Password,
DB: r.DB, DB: r.DB,
PoolSize: r.PoolSize, PoolSize: r.PoolSize,
@ -227,6 +242,7 @@ func createRedisClient(r RedisConnOpt) redis.UniversalClient {
MasterName: r.MasterName, MasterName: r.MasterName,
SentinelAddrs: r.SentinelAddrs, SentinelAddrs: r.SentinelAddrs,
SentinelPassword: r.SentinelPassword, SentinelPassword: r.SentinelPassword,
Username: r.Username,
Password: r.Password, Password: r.Password,
DB: r.DB, DB: r.DB,
PoolSize: r.PoolSize, PoolSize: r.PoolSize,
@ -235,12 +251,14 @@ func createRedisClient(r RedisConnOpt) redis.UniversalClient {
case RedisClusterClientOpt: case RedisClusterClientOpt:
return redis.NewClusterClient(&redis.ClusterOptions{ return redis.NewClusterClient(&redis.ClusterOptions{
Addrs: r.Addrs, Addrs: r.Addrs,
Username: r.Username,
Password: r.Password, Password: r.Password,
TLSConfig: r.TLSConfig, TLSConfig: r.TLSConfig,
}) })
case *RedisClusterClientOpt: case *RedisClusterClientOpt:
return redis.NewClusterClient(&redis.ClusterOptions{ return redis.NewClusterClient(&redis.ClusterOptions{
Addrs: r.Addrs, Addrs: r.Addrs,
Username: r.Username,
Password: r.Password, Password: r.Password,
TLSConfig: r.TLSConfig, TLSConfig: r.TLSConfig,
}) })