Skip to content

Commit 86cf985

Browse files
committed
Improve NewUniversalClient comment
1 parent d678a01 commit 86cf985

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

universal.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,16 @@ var (
259259
// NewUniversalClient returns a new multi client. The type of the returned client depends
260260
// on the following conditions:
261261
//
262-
// 1. If the MasterName option is specified, a sentinel-backed FailoverClient is returned.
263-
// 2. if the number of Addrs is two or more, a ClusterClient is returned.
262+
// 1. If the MasterName option is specified with RouteByLatency, RouteRandomly or IsClusterMode,
263+
// a FailoverClusterClient is returned.
264+
// 2. If the MasterName option is specified without RouteByLatency, RouteRandomly or IsClusterMode,
265+
// a sentinel-backed FailoverClient is returned.
266+
// 2. If the number of Addrs is two or more, or IsClusterMode option is specified,
267+
// a ClusterClient is returned.
264268
// 3. Otherwise, a single-node Client is returned.
265269
func NewUniversalClient(opts *UniversalOptions) UniversalClient {
266270
switch {
267-
case opts.MasterName != "" && (opts.RouteByLatency || opts.RouteRandomly):
271+
case opts.MasterName != "" && (opts.RouteByLatency || opts.RouteRandomly || opts.IsClusterMode):
268272
return NewFailoverClusterClient(opts.Failover())
269273
case opts.MasterName != "":
270274
return NewFailoverClient(opts.Failover())

0 commit comments

Comments
 (0)