Skip to content

Commit 140a278

Browse files
committed
add streamingcredentialsprovider in options
1 parent df9bfce commit 140a278

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

options.go

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"strings"
1414
"time"
1515

16+
"github.com/redis/go-redis/v9/auth"
1617
"github.com/redis/go-redis/v9/internal/pool"
1718
)
1819

@@ -74,6 +75,14 @@ type Options struct {
7475
// There will be a conflict between them; if CredentialsProviderContext exists, we will ignore CredentialsProvider.
7576
CredentialsProviderContext func(ctx context.Context) (username string, password string, err error)
7677

78+
// StreamingCredentialsProvider is used to retrieve the credentials
79+
// for the connection from an external source. Those credentials may change
80+
// during the connection lifetime. This is useful for managed identity
81+
// scenarios where the credentials are retrieved from an external source.
82+
//
83+
// Currently, this is a placeholder for the future implementation.
84+
StreamingCredentialsProvider auth.StreamingCredentialsProvider
85+
7786
// DB is the database to be selected after connecting to the server.
7887
DB int
7988

osscluster.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"sync/atomic"
1515
"time"
1616

17+
"github.com/redis/go-redis/v9/auth"
1718
"github.com/redis/go-redis/v9/internal"
1819
"github.com/redis/go-redis/v9/internal/hashtag"
1920
"github.com/redis/go-redis/v9/internal/pool"
@@ -66,11 +67,12 @@ type ClusterOptions struct {
6667

6768
OnConnect func(ctx context.Context, cn *Conn) error
6869

69-
Protocol int
70-
Username string
71-
Password string
72-
CredentialsProvider func() (username string, password string)
73-
CredentialsProviderContext func(ctx context.Context) (username string, password string, err error)
70+
Protocol int
71+
Username string
72+
Password string
73+
CredentialsProvider func() (username string, password string)
74+
CredentialsProviderContext func(ctx context.Context) (username string, password string, err error)
75+
StreamingCredentialsProvider auth.StreamingCredentialsProvider
7476

7577
MaxRetries int
7678
MinRetryBackoff time.Duration
@@ -291,11 +293,12 @@ func (opt *ClusterOptions) clientOptions() *Options {
291293
Dialer: opt.Dialer,
292294
OnConnect: opt.OnConnect,
293295

294-
Protocol: opt.Protocol,
295-
Username: opt.Username,
296-
Password: opt.Password,
297-
CredentialsProvider: opt.CredentialsProvider,
298-
CredentialsProviderContext: opt.CredentialsProviderContext,
296+
Protocol: opt.Protocol,
297+
Username: opt.Username,
298+
Password: opt.Password,
299+
CredentialsProvider: opt.CredentialsProvider,
300+
CredentialsProviderContext: opt.CredentialsProviderContext,
301+
StreamingCredentialsProvider: opt.StreamingCredentialsProvider,
299302

300303
MaxRetries: opt.MaxRetries,
301304
MinRetryBackoff: opt.MinRetryBackoff,

0 commit comments

Comments
 (0)