Skip to content

Commit 647e2bd

Browse files
committed
Add Suffix support to defualt client set info
1 parent 73c879d commit 647e2bd

File tree

6 files changed

+16
-0
lines changed

6 files changed

+16
-0
lines changed

options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ type Options struct {
144144

145145
// Disable set-lib on connect. Default is false.
146146
DisableIndentity bool
147+
148+
// Add suffix to client name. Default is empty.
149+
ClientNameSuffix string
147150
}
148151

149152
func (opt *Options) init() {

osscluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ type ClusterOptions struct {
8686

8787
TLSConfig *tls.Config
8888
DisableIndentity bool // Disable set-lib on connect. Default is false.
89+
90+
ClientNameSuffix string // Add suffix to client name. Default is empty.
8991
}
9092

9193
func (opt *ClusterOptions) init() {
@@ -291,6 +293,7 @@ func (opt *ClusterOptions) clientOptions() *Options {
291293
ConnMaxIdleTime: opt.ConnMaxIdleTime,
292294
ConnMaxLifetime: opt.ConnMaxLifetime,
293295
DisableIndentity: opt.DisableIndentity,
296+
ClientNameSuffix: opt.ClientNameSuffix,
294297
TLSConfig: opt.TLSConfig,
295298
// If ClusterSlots is populated, then we probably have an artificial
296299
// cluster whose nodes are not in clustering mode (otherwise there isn't

redis.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
315315
if !c.opt.DisableIndentity {
316316
libName := ""
317317
libVer := Version()
318+
if c.opt.ClientNameSuffix != "" {
319+
libName = libName + c.opt.ClientNameSuffix
320+
}
318321
libInfo := LibraryInfo{LibName: &libName}
319322
conn.ClientSetInfo(ctx, libInfo)
320323
libInfo = LibraryInfo{LibVer: &libVer}

ring.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ type RingOptions struct {
9999
Limiter Limiter
100100

101101
DisableIndentity bool
102+
ClientNameSuffix string
102103
}
103104

104105
func (opt *RingOptions) init() {

sentinel.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ type FailoverOptions struct {
8181
TLSConfig *tls.Config
8282

8383
DisableIndentity bool
84+
ClientNameSuffix string
8485
}
8586

8687
func (opt *FailoverOptions) clientOptions() *Options {
@@ -117,6 +118,7 @@ func (opt *FailoverOptions) clientOptions() *Options {
117118
TLSConfig: opt.TLSConfig,
118119

119120
DisableIndentity: opt.DisableIndentity,
121+
ClientNameSuffix: opt.ClientNameSuffix,
120122
}
121123
}
122124

universal.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ type UniversalOptions struct {
6767
MasterName string
6868

6969
DisableIndentity bool
70+
ClientNameSuffix string
7071
}
7172

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

114115
DisableIndentity: o.DisableIndentity,
116+
ClientNameSuffix: o.ClientNameSuffix,
115117
}
116118
}
117119

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

159161
DisableIndentity: o.DisableIndentity,
162+
ClientNameSuffix: o.ClientNameSuffix,
160163
}
161164
}
162165

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

201204
DisableIndentity: o.DisableIndentity,
205+
ClientNameSuffix: o.ClientNameSuffix,
202206
}
203207
}
204208

0 commit comments

Comments
 (0)