@@ -53,6 +53,7 @@ type UniversalOptions struct {
5353
5454 // The sentinel master name.
5555 // Only failover clients.
56+
5657 MasterName string
5758}
5859
@@ -168,9 +169,9 @@ func (o *UniversalOptions) Simple() *Options {
168169// --------------------------------------------------------------------
169170
170171// UniversalClient is an abstract client which - based on the provided options -
171- // can connect to either clusters , or sentinel-backed failover instances
172- // or simple single-instance servers. This can be useful for testing
173- // cluster-specific applications locally .
172+ // represents either a ClusterClient, a FailoverClient , or a single-node Client.
173+ // This can be useful for testing cluster-specific applications locally or having different
174+ // clients in different environments .
174175type UniversalClient interface {
175176 Cmdable
176177 Context () context.Context
@@ -190,12 +191,12 @@ var (
190191 _ UniversalClient = (* Ring )(nil )
191192)
192193
193- // NewUniversalClient returns a new multi client. The type of client returned depends
194- // on the following three conditions:
194+ // NewUniversalClient returns a new multi client. The type of the returned client depends
195+ // on the following conditions:
195196//
196- // 1. if a MasterName is passed a sentinel-backed FailoverClient will be returned
197- // 2. if the number of Addrs is two or more, a ClusterClient will be returned
198- // 3. otherwise , a single-node redis Client will be returned.
197+ // 1. If the MasterName option is specified, a sentinel-backed FailoverClient is returned.
198+ // 2. if the number of Addrs is two or more, a ClusterClient is returned.
199+ // 3. Otherwise , a single-node Client is returned.
199200func NewUniversalClient (opts * UniversalOptions ) UniversalClient {
200201 if opts .MasterName != "" {
201202 return NewFailoverClient (opts .Failover ())
0 commit comments