MCPcopy
hub / github.com/redis/go-redis / NewUniversalClient

Function NewUniversalClient

universal.go:380–395  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

378//
379// Passing nil UniversalOptions will cause a panic.
380func 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}

Callers

nothing calls this directly

Calls 7

NewFailoverClusterClientFunction · 0.85
NewFailoverClientFunction · 0.85
NewClusterClientFunction · 0.85
NewClientFunction · 0.85
ClusterMethod · 0.80
SimpleMethod · 0.80
FailoverMethod · 0.45

Tested by

no test coverage detected