NewUniversalClient returns a new multi client. The type of the returned client depends on the following conditions: 1. If the MasterName option is specified with RouteByLatency, RouteRandomly or IsClusterMode, a FailoverClusterClient is returned. 2. If the MasterName option is specified without Rou
(opts *UniversalOptions)
| 378 | // |
| 379 | // Passing nil UniversalOptions will cause a panic. |
| 380 | func NewUniversalClient(opts *UniversalOptions) UniversalClient { |
| 381 | if opts == nil { |
| 382 | panic("redis: NewUniversalClient nil options") |
| 383 | } |
| 384 | |
| 385 | switch { |
| 386 | case opts.MasterName != "" && (opts.RouteByLatency || opts.RouteRandomly || opts.IsClusterMode): |
| 387 | return NewFailoverClusterClient(opts.Failover()) |
| 388 | case opts.MasterName != "": |
| 389 | return NewFailoverClient(opts.Failover()) |
| 390 | case len(opts.Addrs) > 1 || opts.IsClusterMode: |
| 391 | return NewClusterClient(opts.Cluster()) |
| 392 | default: |
| 393 | return NewClient(opts.Simple()) |
| 394 | } |
| 395 | } |
nothing calls this directly
no test coverage detected