1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

feat: add ClientName option

Signed-off-by: monkey92t <golang@88.com>
This commit is contained in:
monkey92t
2022-12-28 22:14:52 +08:00
parent f70c952806
commit a872c35b1a
11 changed files with 121 additions and 15 deletions

View File

@ -27,7 +27,7 @@ type Limiter interface {
ReportResult(result error)
}
// Options keeps the settings to setup redis connection.
// Options keeps the settings to set up redis connection.
type Options struct {
// The network type, either tcp or unix.
// Default is tcp.
@ -35,6 +35,9 @@ type Options struct {
// host:port address.
Addr string
// ClientName will execute the `CLIENT SETNAME ClientName` command for each conn.
ClientName string
// Dialer creates new network connection and has priority over
// Network and Addr options.
Dialer func(ctx context.Context, network, addr string) (net.Conn, error)
@ -426,6 +429,7 @@ func setupConnParams(u *url.URL, o *Options) (*Options, error) {
o.DB = db
}
o.ClientName = q.string("client_name")
o.MaxRetries = q.int("max_retries")
o.MinRetryBackoff = q.duration("min_retry_backoff")
o.MaxRetryBackoff = q.duration("max_retry_backoff")