@@ -88,3 +88,63 @@ func (o *Options) redisOptions() *redis.Options {
8888 TLSConfig : o .TLSConfig ,
8989 }
9090}
91+
92+ // ClusterOptions are used to configure a cluster client and should be
93+ // passed to NewClusterClient.
94+ type ClusterOptions struct {
95+ // A seed list of host:port addresses of cluster nodes.
96+ Addrs []string
97+
98+ // The maximum number of retries before giving up. Command is retried
99+ // on network errors and MOVED/ASK redirects.
100+ // Default is 8.
101+ MaxRedirects int
102+
103+ // Enables read-only commands on slave nodes.
104+ ReadOnly bool
105+ // Allows routing read-only commands to the closest master or slave node.
106+ RouteByLatency bool
107+ // Allows routing read-only commands to the random master or slave node.
108+ RouteRandomly bool
109+
110+ // Following options are copied from Options struct.
111+
112+ OnConnect func (* redis.Conn ) error
113+
114+ MaxRetries int
115+ MinRetryBackoff time.Duration
116+ MaxRetryBackoff time.Duration
117+ Password string
118+
119+ DialTimeout time.Duration
120+ ReadTimeout time.Duration
121+ WriteTimeout time.Duration
122+
123+ // PoolSize applies per cluster node and not for the whole cluster.
124+ PoolSize int
125+ PoolTimeout time.Duration
126+ IdleTimeout time.Duration
127+ IdleCheckFrequency time.Duration
128+ }
129+
130+ func (o * ClusterOptions ) redisClusterOptions () * redis.ClusterOptions {
131+ return & redis.ClusterOptions {
132+ Addrs : o .Addrs ,
133+ MaxRedirects : o .MaxRedirects ,
134+ ReadOnly : o .ReadOnly ,
135+ RouteByLatency : o .RouteByLatency ,
136+ RouteRandomly : o .RouteRandomly ,
137+ OnConnect : o .OnConnect ,
138+ MaxRetries : o .MaxRetries ,
139+ MinRetryBackoff : o .MinRetryBackoff ,
140+ MaxRetryBackoff : o .MaxRetryBackoff ,
141+ Password : o .Password ,
142+ DialTimeout : o .DialTimeout ,
143+ ReadTimeout : o .ReadTimeout ,
144+ WriteTimeout : o .WriteTimeout ,
145+ PoolSize : o .PoolSize ,
146+ PoolTimeout : o .PoolTimeout ,
147+ IdleTimeout : o .IdleTimeout ,
148+ IdleCheckFrequency : o .IdleCheckFrequency ,
149+ }
150+ }
0 commit comments