Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CredentialsProvider field to UniversalOptions #2927

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions ring.go
Expand Up @@ -70,10 +70,11 @@ type RingOptions struct {
Dialer func(ctx context.Context, network, addr string) (net.Conn, error)
OnConnect func(ctx context.Context, cn *Conn) error

Protocol int
Username string
Password string
DB int
Protocol int
Username string
Password string
CredentialsProvider func() (username string, password string)
DB int

MaxRetries int
MinRetryBackoff time.Duration
Expand Down Expand Up @@ -142,10 +143,11 @@ func (opt *RingOptions) clientOptions() *Options {
Dialer: opt.Dialer,
OnConnect: opt.OnConnect,

Protocol: opt.Protocol,
Username: opt.Username,
Password: opt.Password,
DB: opt.DB,
Protocol: opt.Protocol,
Username: opt.Username,
Password: opt.Password,
CredentialsProvider: opt.CredentialsProvider,
DB: opt.DB,

MaxRetries: -1,

Expand Down
25 changes: 14 additions & 11 deletions sentinel.go
Expand Up @@ -54,10 +54,11 @@ type FailoverOptions struct {
Dialer func(ctx context.Context, network, addr string) (net.Conn, error)
OnConnect func(ctx context.Context, cn *Conn) error

Protocol int
Username string
Password string
DB int
Protocol int
Username string
Password string
CredentialsProvider func() (username string, password string)
DB int

MaxRetries int
MinRetryBackoff time.Duration
Expand Down Expand Up @@ -92,10 +93,11 @@ func (opt *FailoverOptions) clientOptions() *Options {
Dialer: opt.Dialer,
OnConnect: opt.OnConnect,

DB: opt.DB,
Protocol: opt.Protocol,
Username: opt.Username,
Password: opt.Password,
DB: opt.DB,
Protocol: opt.Protocol,
Username: opt.Username,
Password: opt.Password,
CredentialsProvider: opt.CredentialsProvider,

MaxRetries: opt.MaxRetries,
MinRetryBackoff: opt.MinRetryBackoff,
Expand Down Expand Up @@ -166,9 +168,10 @@ func (opt *FailoverOptions) clusterOptions() *ClusterOptions {
Dialer: opt.Dialer,
OnConnect: opt.OnConnect,

Protocol: opt.Protocol,
Username: opt.Username,
Password: opt.Password,
Protocol: opt.Protocol,
Username: opt.Username,
Password: opt.Password,
CredentialsProvider: opt.CredentialsProvider,

MaxRedirects: opt.MaxRetries,

Expand Down
34 changes: 20 additions & 14 deletions universal.go
Expand Up @@ -26,9 +26,11 @@ type UniversalOptions struct {
Dialer func(ctx context.Context, network, addr string) (net.Conn, error)
OnConnect func(ctx context.Context, cn *Conn) error

Protocol int
Username string
Password string
Protocol int
Username string
Password string
CredentialsProvider func() (username string, password string)

SentinelUsername string
SentinelPassword string

Expand Down Expand Up @@ -82,9 +84,10 @@ func (o *UniversalOptions) Cluster() *ClusterOptions {
Dialer: o.Dialer,
OnConnect: o.OnConnect,

Protocol: o.Protocol,
Username: o.Username,
Password: o.Password,
Protocol: o.Protocol,
Username: o.Username,
Password: o.Password,
CredentialsProvider: o.CredentialsProvider,

MaxRedirects: o.MaxRedirects,
ReadOnly: o.ReadOnly,
Expand Down Expand Up @@ -131,10 +134,12 @@ func (o *UniversalOptions) Failover() *FailoverOptions {
Dialer: o.Dialer,
OnConnect: o.OnConnect,

DB: o.DB,
Protocol: o.Protocol,
Username: o.Username,
Password: o.Password,
DB: o.DB,
Protocol: o.Protocol,
Username: o.Username,
Password: o.Password,
CredentialsProvider: o.CredentialsProvider,

SentinelUsername: o.SentinelUsername,
SentinelPassword: o.SentinelPassword,

Expand Down Expand Up @@ -176,10 +181,11 @@ func (o *UniversalOptions) Simple() *Options {
Dialer: o.Dialer,
OnConnect: o.OnConnect,

DB: o.DB,
Protocol: o.Protocol,
Username: o.Username,
Password: o.Password,
DB: o.DB,
Protocol: o.Protocol,
Username: o.Username,
Password: o.Password,
CredentialsProvider: o.CredentialsProvider,

MaxRetries: o.MaxRetries,
MinRetryBackoff: o.MinRetryBackoff,
Expand Down