Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Suffix support to default client set info #2852

Merged
merged 7 commits into from Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions options.go
Expand Up @@ -144,6 +144,9 @@ type Options struct {

// Disable set-lib on connect. Default is false.
DisableIndentity bool

// Add suffix to client name. Default is empty.
ClientNameSuffix string
ofekshenawa marked this conversation as resolved.
Show resolved Hide resolved
}

func (opt *Options) init() {
Expand Down
3 changes: 3 additions & 0 deletions osscluster.go
Expand Up @@ -86,6 +86,8 @@ type ClusterOptions struct {

TLSConfig *tls.Config
DisableIndentity bool // Disable set-lib on connect. Default is false.

ClientNameSuffix string // Add suffix to client name. Default is empty.
}

func (opt *ClusterOptions) init() {
Expand Down Expand Up @@ -291,6 +293,7 @@ func (opt *ClusterOptions) clientOptions() *Options {
ConnMaxIdleTime: opt.ConnMaxIdleTime,
ConnMaxLifetime: opt.ConnMaxLifetime,
DisableIndentity: opt.DisableIndentity,
ClientNameSuffix: opt.ClientNameSuffix,
TLSConfig: opt.TLSConfig,
// If ClusterSlots is populated, then we probably have an artificial
// cluster whose nodes are not in clustering mode (otherwise there isn't
Expand Down
3 changes: 3 additions & 0 deletions redis.go
Expand Up @@ -315,6 +315,9 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
if !c.opt.DisableIndentity {
libName := ""
libVer := Version()
if c.opt.ClientNameSuffix != "" {
ofekshenawa marked this conversation as resolved.
Show resolved Hide resolved
libName = libName + c.opt.ClientNameSuffix
}
libInfo := LibraryInfo{LibName: &libName}
conn.ClientSetInfo(ctx, libInfo)
libInfo = LibraryInfo{LibVer: &libVer}
Expand Down
1 change: 1 addition & 0 deletions ring.go
Expand Up @@ -99,6 +99,7 @@ type RingOptions struct {
Limiter Limiter

DisableIndentity bool
ClientNameSuffix string
}

func (opt *RingOptions) init() {
Expand Down
2 changes: 2 additions & 0 deletions sentinel.go
Expand Up @@ -81,6 +81,7 @@ type FailoverOptions struct {
TLSConfig *tls.Config

DisableIndentity bool
ClientNameSuffix string
}

func (opt *FailoverOptions) clientOptions() *Options {
Expand Down Expand Up @@ -117,6 +118,7 @@ func (opt *FailoverOptions) clientOptions() *Options {
TLSConfig: opt.TLSConfig,

DisableIndentity: opt.DisableIndentity,
ClientNameSuffix: opt.ClientNameSuffix,
}
}

Expand Down
4 changes: 4 additions & 0 deletions universal.go
Expand Up @@ -67,6 +67,7 @@ type UniversalOptions struct {
MasterName string

DisableIndentity bool
ClientNameSuffix string
}

// Cluster returns cluster options created from the universal options.
Expand Down Expand Up @@ -112,6 +113,7 @@ func (o *UniversalOptions) Cluster() *ClusterOptions {
TLSConfig: o.TLSConfig,

DisableIndentity: o.DisableIndentity,
ClientNameSuffix: o.ClientNameSuffix,
}
}

Expand Down Expand Up @@ -157,6 +159,7 @@ func (o *UniversalOptions) Failover() *FailoverOptions {
TLSConfig: o.TLSConfig,

DisableIndentity: o.DisableIndentity,
ClientNameSuffix: o.ClientNameSuffix,
}
}

Expand Down Expand Up @@ -199,6 +202,7 @@ func (o *UniversalOptions) Simple() *Options {
TLSConfig: o.TLSConfig,

DisableIndentity: o.DisableIndentity,
ClientNameSuffix: o.ClientNameSuffix,
}
}

Expand Down