@@ -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"
@@ -57,11 +58,27 @@ type FailoverOptions struct {
5758 Dialer func (ctx context.Context , network , addr string ) (net.Conn , error )
5859 OnConnect func (ctx context.Context , cn * Conn ) error
5960
60- Protocol int
61- Username string
62- Password string
61+ Protocol int
62+ Username string
63+ Password string
64+ // CredentialsProvider allows the username and password to be updated
65+ // before reconnecting. It should return the current username and password.
6366 CredentialsProvider func () (username string , password string )
64- DB int
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
6582
6683 MaxRetries int
6784 MinRetryBackoff time.Duration
@@ -108,11 +125,13 @@ func (opt *FailoverOptions) clientOptions() *Options {
108125 Dialer : opt .Dialer ,
109126 OnConnect : opt .OnConnect ,
110127
111- DB : opt .DB ,
112- Protocol : opt .Protocol ,
113- Username : opt .Username ,
114- Password : opt .Password ,
115- CredentialsProvider : opt .CredentialsProvider ,
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 ,
116135
117136 MaxRetries : opt .MaxRetries ,
118137 MinRetryBackoff : opt .MinRetryBackoff ,
@@ -189,10 +208,12 @@ func (opt *FailoverOptions) clusterOptions() *ClusterOptions {
189208 Dialer : opt .Dialer ,
190209 OnConnect : opt .OnConnect ,
191210
192- Protocol : opt .Protocol ,
193- Username : opt .Username ,
194- Password : opt .Password ,
195- CredentialsProvider : opt .CredentialsProvider ,
211+ Protocol : opt .Protocol ,
212+ Username : opt .Username ,
213+ Password : opt .Password ,
214+ CredentialsProvider : opt .CredentialsProvider ,
215+ CredentialsProviderContext : opt .CredentialsProviderContext ,
216+ StreamingCredentialsProvider : opt .StreamingCredentialsProvider ,
196217
197218 MaxRedirects : opt .MaxRetries ,
198219
0 commit comments