5
5
"crypto/tls"
6
6
"net"
7
7
"time"
8
+
9
+ "github.com/redis/go-redis/v9/auth"
8
10
)
9
11
10
12
// UniversalOptions information is required by UniversalClient to establish
@@ -26,11 +28,27 @@ type UniversalOptions struct {
26
28
Dialer func (ctx context.Context , network , addr string ) (net.Conn , error )
27
29
OnConnect func (ctx context.Context , cn * Conn ) error
28
30
29
- Protocol int
30
- Username string
31
- Password string
31
+ Protocol int
32
+ Username string
33
+ Password string
34
+ // CredentialsProvider allows the username and password to be updated
35
+ // before reconnecting. It should return the current username and password.
32
36
CredentialsProvider func () (username string , password string )
33
37
38
+ // CredentialsProviderContext is an enhanced parameter of CredentialsProvider,
39
+ // done to maintain API compatibility. In the future,
40
+ // there might be a merge between CredentialsProviderContext and CredentialsProvider.
41
+ // There will be a conflict between them; if CredentialsProviderContext exists, we will ignore CredentialsProvider.
42
+ CredentialsProviderContext func (ctx context.Context ) (username string , password string , err error )
43
+
44
+ // StreamingCredentialsProvider is used to retrieve the credentials
45
+ // for the connection from an external source. Those credentials may change
46
+ // during the connection lifetime. This is useful for managed identity
47
+ // scenarios where the credentials are retrieved from an external source.
48
+ //
49
+ // Currently, this is a placeholder for the future implementation.
50
+ StreamingCredentialsProvider auth.StreamingCredentialsProvider
51
+
34
52
SentinelUsername string
35
53
SentinelPassword string
36
54
@@ -98,10 +116,12 @@ func (o *UniversalOptions) Cluster() *ClusterOptions {
98
116
Dialer : o .Dialer ,
99
117
OnConnect : o .OnConnect ,
100
118
101
- Protocol : o .Protocol ,
102
- Username : o .Username ,
103
- Password : o .Password ,
104
- CredentialsProvider : o .CredentialsProvider ,
119
+ Protocol : o .Protocol ,
120
+ Username : o .Username ,
121
+ Password : o .Password ,
122
+ CredentialsProvider : o .CredentialsProvider ,
123
+ CredentialsProviderContext : o .CredentialsProviderContext ,
124
+ StreamingCredentialsProvider : o .StreamingCredentialsProvider ,
105
125
106
126
MaxRedirects : o .MaxRedirects ,
107
127
ReadOnly : o .ReadOnly ,
@@ -150,11 +170,13 @@ func (o *UniversalOptions) Failover() *FailoverOptions {
150
170
Dialer : o .Dialer ,
151
171
OnConnect : o .OnConnect ,
152
172
153
- DB : o .DB ,
154
- Protocol : o .Protocol ,
155
- Username : o .Username ,
156
- Password : o .Password ,
157
- CredentialsProvider : o .CredentialsProvider ,
173
+ DB : o .DB ,
174
+ Protocol : o .Protocol ,
175
+ Username : o .Username ,
176
+ Password : o .Password ,
177
+ CredentialsProvider : o .CredentialsProvider ,
178
+ CredentialsProviderContext : o .CredentialsProviderContext ,
179
+ StreamingCredentialsProvider : o .StreamingCredentialsProvider ,
158
180
159
181
SentinelUsername : o .SentinelUsername ,
160
182
SentinelPassword : o .SentinelPassword ,
@@ -204,11 +226,13 @@ func (o *UniversalOptions) Simple() *Options {
204
226
Dialer : o .Dialer ,
205
227
OnConnect : o .OnConnect ,
206
228
207
- DB : o .DB ,
208
- Protocol : o .Protocol ,
209
- Username : o .Username ,
210
- Password : o .Password ,
211
- CredentialsProvider : o .CredentialsProvider ,
229
+ DB : o .DB ,
230
+ Protocol : o .Protocol ,
231
+ Username : o .Username ,
232
+ Password : o .Password ,
233
+ CredentialsProvider : o .CredentialsProvider ,
234
+ CredentialsProviderContext : o .CredentialsProviderContext ,
235
+ StreamingCredentialsProvider : o .StreamingCredentialsProvider ,
212
236
213
237
MaxRetries : o .MaxRetries ,
214
238
MinRetryBackoff : o .MinRetryBackoff ,
0 commit comments