Skip to content

Commit 8a0ab1a

Browse files
Make universal options functions public (#1250)
* Make universal options functions public
1 parent 2f96fd1 commit 8a0ab1a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

universal.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ type UniversalOptions struct {
4949
MasterName string
5050
}
5151

52-
func (o *UniversalOptions) cluster() *ClusterOptions {
52+
// Cluster returns cluster options created from the universal options.
53+
func (o *UniversalOptions) Cluster() *ClusterOptions {
5354
if len(o.Addrs) == 0 {
5455
o.Addrs = []string{"127.0.0.1:6379"}
5556
}
@@ -84,7 +85,8 @@ func (o *UniversalOptions) cluster() *ClusterOptions {
8485
}
8586
}
8687

87-
func (o *UniversalOptions) failover() *FailoverOptions {
88+
// Failover returns failover options created from the universal options.
89+
func (o *UniversalOptions) Failover() *FailoverOptions {
8890
if len(o.Addrs) == 0 {
8991
o.Addrs = []string{"127.0.0.1:26379"}
9092
}
@@ -118,7 +120,8 @@ func (o *UniversalOptions) failover() *FailoverOptions {
118120
}
119121
}
120122

121-
func (o *UniversalOptions) simple() *Options {
123+
// Simple returns basic options created from the universal options.
124+
func (o *UniversalOptions) Simple() *Options {
122125
addr := "127.0.0.1:6379"
123126
if len(o.Addrs) > 0 {
124127
addr = o.Addrs[0]
@@ -183,9 +186,9 @@ var _ UniversalClient = (*Ring)(nil)
183186
// 3. otherwise, a single-node redis Client will be returned.
184187
func NewUniversalClient(opts *UniversalOptions) UniversalClient {
185188
if opts.MasterName != "" {
186-
return NewFailoverClient(opts.failover())
189+
return NewFailoverClient(opts.Failover())
187190
} else if len(opts.Addrs) > 1 {
188-
return NewClusterClient(opts.cluster())
191+
return NewClusterClient(opts.Cluster())
189192
}
190-
return NewClient(opts.simple())
193+
return NewClient(opts.Simple())
191194
}

0 commit comments

Comments
 (0)