Skip to content

Commit df9bfce

Browse files
committed
update documentation
1 parent 9ef438b commit df9bfce

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

auth/auth.go

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
11
package auth
22

3+
// StreamingCredentialsProvider is an interface that defines the methods for a streaming credentials provider.
4+
// It is used to provide credentials for authentication.
5+
// The CredentialsListener is used to receive updates when the credentials change.
36
type StreamingCredentialsProvider interface {
4-
// Subscribe subscribes to the credentials provider and returns a channel that will receive updates.
5-
// The first response is blocking, then data will be pushed to the channel.
7+
// Subscribe subscribes to the credentials provider for updates.
8+
// It returns the current credentials, a cancel function to unsubscribe from the provider,
9+
// and an error if any.
610
Subscribe(listener CredentialsListener) (Credentials, CancelProviderFunc, error)
711
}
812

13+
// CancelProviderFunc is a function that is used to cancel the subscription to the credentials provider.
14+
// It is used to unsubscribe from the provider when the credentials are no longer needed.
915
type CancelProviderFunc func() error
1016

17+
// CredentialsListener is an interface that defines the methods for a credentials listener.
18+
// It is used to receive updates when the credentials change.
19+
// The OnNext method is called when the credentials change.
20+
// The OnError method is called when an error occurs while requesting the credentials.
1121
type CredentialsListener interface {
1222
OnNext(credentials Credentials)
1323
OnError(err error)
1424
}
1525

26+
// Credentials is an interface that defines the methods for credentials.
27+
// It is used to provide the credentials for authentication.
1628
type Credentials interface {
29+
// BasicAuth returns the username and password for basic authentication.
1730
BasicAuth() (username string, password string)
31+
// RawCredentials returns the raw credentials as a string.
32+
// This can be used to extract the username and password from the raw credentials or
33+
// additional information if present in the token.
1834
RawCredentials() string
1935
}
2036

@@ -23,15 +39,18 @@ type basicAuth struct {
2339
password string
2440
}
2541

42+
// RawCredentials returns the raw credentials as a string.
2643
func (b *basicAuth) RawCredentials() string {
2744
return b.username + ":" + b.password
2845
}
2946

47+
// BasicAuth returns the username and password for basic authentication.
3048
func (b *basicAuth) BasicAuth() (username string, password string) {
3149
return b.username, b.password
3250
}
3351

34-
func NewCredentials(username, password string) Credentials {
52+
// NewBasicCredentials creates a new Credentials object from the given username and password.
53+
func NewBasicCredentials(username, password string) Credentials {
3554
return &basicAuth{
3655
username: username,
3756
password: password,

redis.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
336336
}
337337

338338
if !authenticated && password != "" {
339-
err = c.reAuth(ctx, conn, auth.NewCredentials(username, password))
339+
err = c.reAuth(ctx, conn, auth.NewBasicCredentials(username, password))
340340
if err != nil {
341341
return err
342342
}

0 commit comments

Comments
 (0)