()
| 195 | } |
| 196 | |
| 197 | func (opt *ClusterOptions) init() { |
| 198 | switch opt.MaxRedirects { |
| 199 | case -1: |
| 200 | opt.MaxRedirects = 0 |
| 201 | case 0: |
| 202 | opt.MaxRedirects = 3 |
| 203 | } |
| 204 | |
| 205 | if opt.RouteByLatency || opt.RouteRandomly { |
| 206 | opt.ReadOnly = true |
| 207 | } |
| 208 | |
| 209 | if opt.DialTimeout == 0 { |
| 210 | opt.DialTimeout = 5 * time.Second |
| 211 | } |
| 212 | if opt.DialerRetries == 0 { |
| 213 | opt.DialerRetries = 5 |
| 214 | } |
| 215 | if opt.DialerRetryTimeout == 0 { |
| 216 | opt.DialerRetryTimeout = 100 * time.Millisecond |
| 217 | } |
| 218 | |
| 219 | if opt.PoolSize == 0 { |
| 220 | opt.PoolSize = 5 * runtime.GOMAXPROCS(0) |
| 221 | } |
| 222 | if opt.MaxConcurrentDials <= 0 { |
| 223 | opt.MaxConcurrentDials = opt.PoolSize |
| 224 | } else if opt.MaxConcurrentDials > opt.PoolSize { |
| 225 | opt.MaxConcurrentDials = opt.PoolSize |
| 226 | } |
| 227 | if opt.ReadBufferSize == 0 { |
| 228 | opt.ReadBufferSize = proto.DefaultBufferSize |
| 229 | } |
| 230 | if opt.WriteBufferSize == 0 { |
| 231 | opt.WriteBufferSize = proto.DefaultBufferSize |
| 232 | } |
| 233 | |
| 234 | switch opt.ReadTimeout { |
| 235 | case -1: |
| 236 | opt.ReadTimeout = 0 |
| 237 | case 0: |
| 238 | opt.ReadTimeout = 3 * time.Second |
| 239 | } |
| 240 | switch opt.WriteTimeout { |
| 241 | case -1: |
| 242 | opt.WriteTimeout = 0 |
| 243 | case 0: |
| 244 | opt.WriteTimeout = opt.ReadTimeout |
| 245 | } |
| 246 | |
| 247 | if opt.MaxRetries == 0 { |
| 248 | opt.MaxRetries = -1 |
| 249 | } |
| 250 | switch opt.MinRetryBackoff { |
| 251 | case -1: |
| 252 | opt.MinRetryBackoff = 0 |
| 253 | case 0: |
| 254 | opt.MinRetryBackoff = 8 * time.Millisecond |
no outgoing calls