Update comments

This commit is contained in:
Vladimir Mihailenco 2021-04-08 10:02:22 +03:00
parent 8b2a7107ee
commit d67e2911b9
1 changed files with 9 additions and 8 deletions

View File

@ -53,6 +53,7 @@ type UniversalOptions struct {
// The sentinel master name. // The sentinel master name.
// Only failover clients. // Only failover clients.
MasterName string MasterName string
} }
@ -168,9 +169,9 @@ func (o *UniversalOptions) Simple() *Options {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// UniversalClient is an abstract client which - based on the provided options - // UniversalClient is an abstract client which - based on the provided options -
// can connect to either clusters, or sentinel-backed failover instances // represents either a ClusterClient, a FailoverClient, or a single-node Client.
// or simple single-instance servers. This can be useful for testing // This can be useful for testing cluster-specific applications locally or having different
// cluster-specific applications locally. // clients in different environments.
type UniversalClient interface { type UniversalClient interface {
Cmdable Cmdable
Context() context.Context Context() context.Context
@ -190,12 +191,12 @@ var (
_ UniversalClient = (*Ring)(nil) _ UniversalClient = (*Ring)(nil)
) )
// NewUniversalClient returns a new multi client. The type of client returned depends // NewUniversalClient returns a new multi client. The type of the returned client depends
// on the following three conditions: // on the following conditions:
// //
// 1. if a MasterName is passed a sentinel-backed FailoverClient will be returned // 1. If the MasterName option is specified, a sentinel-backed FailoverClient is returned.
// 2. if the number of Addrs is two or more, a ClusterClient will be returned // 2. if the number of Addrs is two or more, a ClusterClient is returned.
// 3. otherwise, a single-node redis Client will be returned. // 3. Otherwise, a single-node Client is returned.
func NewUniversalClient(opts *UniversalOptions) UniversalClient { func NewUniversalClient(opts *UniversalOptions) UniversalClient {
if opts.MasterName != "" { if opts.MasterName != "" {
return NewFailoverClient(opts.Failover()) return NewFailoverClient(opts.Failover())