@@ -12,6 +12,7 @@ import (
12
12
"sync"
13
13
"time"
14
14
15
+ "github.com/redis/go-redis/v9/auth"
15
16
"github.com/redis/go-redis/v9/internal"
16
17
"github.com/redis/go-redis/v9/internal/pool"
17
18
"github.com/redis/go-redis/v9/internal/rand"
@@ -57,11 +58,27 @@ type FailoverOptions struct {
57
58
Dialer func (ctx context.Context , network , addr string ) (net.Conn , error )
58
59
OnConnect func (ctx context.Context , cn * Conn ) error
59
60
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.
63
66
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
65
82
66
83
MaxRetries int
67
84
MinRetryBackoff time.Duration
@@ -108,11 +125,13 @@ func (opt *FailoverOptions) clientOptions() *Options {
108
125
Dialer : opt .Dialer ,
109
126
OnConnect : opt .OnConnect ,
110
127
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 ,
116
135
117
136
MaxRetries : opt .MaxRetries ,
118
137
MinRetryBackoff : opt .MinRetryBackoff ,
@@ -189,10 +208,12 @@ func (opt *FailoverOptions) clusterOptions() *ClusterOptions {
189
208
Dialer : opt .Dialer ,
190
209
OnConnect : opt .OnConnect ,
191
210
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 ,
196
217
197
218
MaxRedirects : opt .MaxRetries ,
198
219
0 commit comments