@@ -12,6 +12,7 @@ import (
1212 "sync"
1313 "time"
1414
15+ "github.com/redis/go-redis/v9/auth"
1516 "github.com/redis/go-redis/v9/internal"
1617 "github.com/redis/go-redis/v9/internal/pool"
1718 "github.com/redis/go-redis/v9/internal/rand"
@@ -60,7 +61,24 @@ type FailoverOptions struct {
6061 Protocol int
6162 Username string
6263 Password string
63- DB int
64+ // CredentialsProvider allows the username and password to be updated
65+ // before reconnecting. It should return the current username and password.
66+ CredentialsProvider func () (username string , password string )
67+
68+ // CredentialsProviderContext is an enhanced parameter of CredentialsProvider,
69+ // done to maintain API compatibility. In the future,
70+ // there might be a merge between CredentialsProviderContext and CredentialsProvider.
71+ // There will be a conflict between them; if CredentialsProviderContext exists, we will ignore CredentialsProvider.
72+ CredentialsProviderContext func (ctx context.Context ) (username string , password string , err error )
73+
74+ // StreamingCredentialsProvider is used to retrieve the credentials
75+ // for the connection from an external source. Those credentials may change
76+ // during the connection lifetime. This is useful for managed identity
77+ // scenarios where the credentials are retrieved from an external source.
78+ //
79+ // Currently, this is a placeholder for the future implementation.
80+ StreamingCredentialsProvider auth.StreamingCredentialsProvider
81+ DB int
6482
6583 MaxRetries int
6684 MinRetryBackoff time.Duration
@@ -107,10 +125,13 @@ func (opt *FailoverOptions) clientOptions() *Options {
107125 Dialer : opt .Dialer ,
108126 OnConnect : opt .OnConnect ,
109127
110- DB : opt .DB ,
111- Protocol : opt .Protocol ,
112- Username : opt .Username ,
113- Password : opt .Password ,
128+ DB : opt .DB ,
129+ Protocol : opt .Protocol ,
130+ Username : opt .Username ,
131+ Password : opt .Password ,
132+ CredentialsProvider : opt .CredentialsProvider ,
133+ CredentialsProviderContext : opt .CredentialsProviderContext ,
134+ StreamingCredentialsProvider : opt .StreamingCredentialsProvider ,
114135
115136 MaxRetries : opt .MaxRetries ,
116137 MinRetryBackoff : opt .MinRetryBackoff ,
@@ -187,9 +208,12 @@ func (opt *FailoverOptions) clusterOptions() *ClusterOptions {
187208 Dialer : opt .Dialer ,
188209 OnConnect : opt .OnConnect ,
189210
190- Protocol : opt .Protocol ,
191- Username : opt .Username ,
192- Password : opt .Password ,
211+ Protocol : opt .Protocol ,
212+ Username : opt .Username ,
213+ Password : opt .Password ,
214+ CredentialsProvider : opt .CredentialsProvider ,
215+ CredentialsProviderContext : opt .CredentialsProviderContext ,
216+ StreamingCredentialsProvider : opt .StreamingCredentialsProvider ,
193217
194218 MaxRedirects : opt .MaxRetries ,
195219
0 commit comments