2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-26 07:42:17 +08:00

Add MaxRedirects field in RedisClusterClientOpt

This commit is contained in:
Ken Hibino 2020-09-08 05:56:45 -07:00
parent 6e294a7013
commit 450a9aa1e2

View File

@ -115,6 +115,11 @@ 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
// The maximum number of retries before giving up.
// Command is retried on network errors and MOVED/ASK redirects.
// Default is 8 retries.
MaxRedirects int
// Username to authenticate the current connection when Redis ACLs are used. // Username to authenticate the current connection when Redis ACLs are used.
// See: https://redis.io/commands/auth. // See: https://redis.io/commands/auth.
Username string Username string
@ -250,17 +255,19 @@ 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, MaxRedirects: r.MaxRedirects,
Password: r.Password, Username: r.Username,
TLSConfig: r.TLSConfig, Password: r.Password,
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, MaxRedirects: r.MaxRedirects,
Password: r.Password, Username: r.Username,
TLSConfig: r.TLSConfig, Password: r.Password,
TLSConfig: r.TLSConfig,
}) })
default: default:
panic(fmt.Sprintf("asynq: unexpected type %T for RedisConnOpt", r)) panic(fmt.Sprintf("asynq: unexpected type %T for RedisConnOpt", r))