From a32be3d93d60b9b9a3711bb3c248684246168bae Mon Sep 17 00:00:00 2001 From: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> Date: Thu, 4 Jan 2024 14:40:14 +0200 Subject: [PATCH 1/3] Add Suffix support to default client set info (#2852) * Add Suffix support to defualt client set info * Change ClientNameSuffix to IdentitySuffix * add tests --- commands_test.go | 11 +++++++++++ options.go | 3 +++ osscluster.go | 3 +++ redis.go | 3 +++ ring.go | 2 ++ sentinel.go | 2 ++ universal.go | 4 ++++ 7 files changed, 28 insertions(+) diff --git a/commands_test.go b/commands_test.go index 4e9cf195d..af8b0c62f 100644 --- a/commands_test.go +++ b/commands_test.go @@ -291,6 +291,17 @@ var _ = Describe("Commands", func() { }() pipe.ClientSetInfo(ctx, libInfo) }).To(Panic()) + // Test setting the default options for libName, libName suffix and libVer + clientInfo := client.ClientInfo(ctx).Val() + Expect(clientInfo.LibName).To(ContainSubstring("go-redis(go-redis,")) + // Test setting the libName suffix in options + opt := redisOptions() + opt.IdentitySuffix = "suffix" + client2 := redis.NewClient(opt) + defer client2.Close() + clientInfo = client2.ClientInfo(ctx).Val() + Expect(clientInfo.LibName).To(ContainSubstring("go-redis(suffix,")) + }) It("should ConfigGet", func() { diff --git a/options.go b/options.go index 449a92521..dff52ae8b 100644 --- a/options.go +++ b/options.go @@ -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. + IdentitySuffix string } func (opt *Options) init() { diff --git a/osscluster.go b/osscluster.go index b8a82d9bc..9e5eb0464 100644 --- a/osscluster.go +++ b/osscluster.go @@ -86,6 +86,8 @@ type ClusterOptions struct { TLSConfig *tls.Config DisableIndentity bool // Disable set-lib on connect. Default is false. + + IdentitySuffix string // Add suffix to client name. Default is empty. } func (opt *ClusterOptions) init() { @@ -291,6 +293,7 @@ func (opt *ClusterOptions) clientOptions() *Options { ConnMaxIdleTime: opt.ConnMaxIdleTime, ConnMaxLifetime: opt.ConnMaxLifetime, DisableIndentity: opt.DisableIndentity, + IdentitySuffix: opt.IdentitySuffix, 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 diff --git a/redis.go b/redis.go index 9792af760..4dd862b84 100644 --- a/redis.go +++ b/redis.go @@ -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.IdentitySuffix != "" { + libName = c.opt.IdentitySuffix + } libInfo := LibraryInfo{LibName: &libName} conn.ClientSetInfo(ctx, libInfo) libInfo = LibraryInfo{LibVer: &libVer} diff --git a/ring.go b/ring.go index 0c031b5a6..4ae00542b 100644 --- a/ring.go +++ b/ring.go @@ -99,6 +99,7 @@ type RingOptions struct { Limiter Limiter DisableIndentity bool + IdentitySuffix string } func (opt *RingOptions) init() { @@ -166,6 +167,7 @@ func (opt *RingOptions) clientOptions() *Options { Limiter: opt.Limiter, DisableIndentity: opt.DisableIndentity, + IdentitySuffix: opt.IdentitySuffix, } } diff --git a/sentinel.go b/sentinel.go index 31ea3c77a..9ace0886b 100644 --- a/sentinel.go +++ b/sentinel.go @@ -81,6 +81,7 @@ type FailoverOptions struct { TLSConfig *tls.Config DisableIndentity bool + IdentitySuffix string } func (opt *FailoverOptions) clientOptions() *Options { @@ -117,6 +118,7 @@ func (opt *FailoverOptions) clientOptions() *Options { TLSConfig: opt.TLSConfig, DisableIndentity: opt.DisableIndentity, + IdentitySuffix: opt.IdentitySuffix, } } diff --git a/universal.go b/universal.go index 1e48d7b90..275bef3d6 100644 --- a/universal.go +++ b/universal.go @@ -67,6 +67,7 @@ type UniversalOptions struct { MasterName string DisableIndentity bool + IdentitySuffix string } // Cluster returns cluster options created from the universal options. @@ -112,6 +113,7 @@ func (o *UniversalOptions) Cluster() *ClusterOptions { TLSConfig: o.TLSConfig, DisableIndentity: o.DisableIndentity, + IdentitySuffix: o.IdentitySuffix, } } @@ -157,6 +159,7 @@ func (o *UniversalOptions) Failover() *FailoverOptions { TLSConfig: o.TLSConfig, DisableIndentity: o.DisableIndentity, + IdentitySuffix: o.IdentitySuffix, } } @@ -199,6 +202,7 @@ func (o *UniversalOptions) Simple() *Options { TLSConfig: o.TLSConfig, DisableIndentity: o.DisableIndentity, + IdentitySuffix: o.IdentitySuffix, } } From 27581fcb437fa7387d1dcfb6a43c5ccf1f4d2273 Mon Sep 17 00:00:00 2001 From: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> Date: Sun, 7 Jan 2024 11:57:20 +0200 Subject: [PATCH 2/3] Change Z Member type to interface (#2861) --- commands_test.go | 8 ++++---- sortedset_commands.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/commands_test.go b/commands_test.go index af8b0c62f..3d2ebf514 100644 --- a/commands_test.go +++ b/commands_test.go @@ -3733,28 +3733,28 @@ var _ = Describe("Commands", func() { It("should ZAdd bytes", func() { added, err := client.ZAdd(ctx, "zset", redis.Z{ Score: 1, - Member: "one", + Member: []byte("one"), }).Result() Expect(err).NotTo(HaveOccurred()) Expect(added).To(Equal(int64(1))) added, err = client.ZAdd(ctx, "zset", redis.Z{ Score: 1, - Member: "uno", + Member: []byte("uno"), }).Result() Expect(err).NotTo(HaveOccurred()) Expect(added).To(Equal(int64(1))) added, err = client.ZAdd(ctx, "zset", redis.Z{ Score: 2, - Member: "two", + Member: []byte("two"), }).Result() Expect(err).NotTo(HaveOccurred()) Expect(added).To(Equal(int64(1))) added, err = client.ZAdd(ctx, "zset", redis.Z{ Score: 3, - Member: "two", + Member: []byte("two"), }).Result() Expect(err).NotTo(HaveOccurred()) Expect(added).To(Equal(int64(0))) diff --git a/sortedset_commands.go b/sortedset_commands.go index 7e96e1ebf..670140270 100644 --- a/sortedset_commands.go +++ b/sortedset_commands.go @@ -727,7 +727,7 @@ func (c cmdable) ZScan(ctx context.Context, key string, cursor uint64, match str // Z represents sorted set member. type Z struct { Score float64 - Member string + Member interface{} } // ZWithKey represents sorted set member including the name of the key where it was popped. From 531f06861b26fc01b1b75f777d7155d286b0943c Mon Sep 17 00:00:00 2001 From: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> Date: Sun, 7 Jan 2024 12:27:07 +0200 Subject: [PATCH 3/3] 9.4.0 (#2862) --- example/del-keys-without-ttl/go.mod | 2 +- example/hll/go.mod | 2 +- example/lua-scripting/go.mod | 2 +- example/otel/go.mod | 6 +++--- example/redis-bloom/go.mod | 2 +- example/scan-struct/go.mod | 2 +- extra/rediscensus/go.mod | 4 ++-- extra/rediscmd/go.mod | 2 +- extra/redisotel/go.mod | 4 ++-- extra/redisprometheus/go.mod | 2 +- package.json | 2 +- version.go | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/example/del-keys-without-ttl/go.mod b/example/del-keys-without-ttl/go.mod index c444600d7..c37ea4ad4 100644 --- a/example/del-keys-without-ttl/go.mod +++ b/example/del-keys-without-ttl/go.mod @@ -5,7 +5,7 @@ go 1.18 replace github.com/redis/go-redis/v9 => ../.. require ( - github.com/redis/go-redis/v9 v9.3.1 + github.com/redis/go-redis/v9 v9.4.0 go.uber.org/zap v1.24.0 ) diff --git a/example/hll/go.mod b/example/hll/go.mod index 1009048bb..37b8b7ca5 100644 --- a/example/hll/go.mod +++ b/example/hll/go.mod @@ -4,7 +4,7 @@ go 1.18 replace github.com/redis/go-redis/v9 => ../.. -require github.com/redis/go-redis/v9 v9.3.1 +require github.com/redis/go-redis/v9 v9.4.0 require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect diff --git a/example/lua-scripting/go.mod b/example/lua-scripting/go.mod index 6c99432a9..52d397635 100644 --- a/example/lua-scripting/go.mod +++ b/example/lua-scripting/go.mod @@ -4,7 +4,7 @@ go 1.18 replace github.com/redis/go-redis/v9 => ../.. -require github.com/redis/go-redis/v9 v9.3.1 +require github.com/redis/go-redis/v9 v9.4.0 require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect diff --git a/example/otel/go.mod b/example/otel/go.mod index 215dfa3c8..4d2d9df81 100644 --- a/example/otel/go.mod +++ b/example/otel/go.mod @@ -9,8 +9,8 @@ replace github.com/redis/go-redis/extra/redisotel/v9 => ../../extra/redisotel replace github.com/redis/go-redis/extra/rediscmd/v9 => ../../extra/rediscmd require ( - github.com/redis/go-redis/extra/redisotel/v9 v9.3.1 - github.com/redis/go-redis/v9 v9.3.1 + github.com/redis/go-redis/extra/redisotel/v9 v9.4.0 + github.com/redis/go-redis/v9 v9.4.0 github.com/uptrace/uptrace-go v1.16.0 go.opentelemetry.io/otel v1.16.0 ) @@ -23,7 +23,7 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 // indirect - github.com/redis/go-redis/extra/rediscmd/v9 v9.3.1 // indirect + github.com/redis/go-redis/extra/rediscmd/v9 v9.4.0 // indirect go.opentelemetry.io/contrib/instrumentation/runtime v0.42.0 // indirect go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0 // indirect diff --git a/example/redis-bloom/go.mod b/example/redis-bloom/go.mod index 0753e0fdd..d7af7cfab 100644 --- a/example/redis-bloom/go.mod +++ b/example/redis-bloom/go.mod @@ -4,7 +4,7 @@ go 1.18 replace github.com/redis/go-redis/v9 => ../.. -require github.com/redis/go-redis/v9 v9.3.1 +require github.com/redis/go-redis/v9 v9.4.0 require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect diff --git a/example/scan-struct/go.mod b/example/scan-struct/go.mod index 7f65f0f43..84d8e4a6b 100644 --- a/example/scan-struct/go.mod +++ b/example/scan-struct/go.mod @@ -6,7 +6,7 @@ replace github.com/redis/go-redis/v9 => ../.. require ( github.com/davecgh/go-spew v1.1.1 - github.com/redis/go-redis/v9 v9.3.1 + github.com/redis/go-redis/v9 v9.4.0 ) require ( diff --git a/extra/rediscensus/go.mod b/extra/rediscensus/go.mod index e536a2330..adf5a9f6e 100644 --- a/extra/rediscensus/go.mod +++ b/extra/rediscensus/go.mod @@ -8,7 +8,7 @@ replace github.com/redis/go-redis/extra/rediscmd/v9 => ../rediscmd require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/redis/go-redis/extra/rediscmd/v9 v9.3.1 - github.com/redis/go-redis/v9 v9.3.1 + github.com/redis/go-redis/extra/rediscmd/v9 v9.4.0 + github.com/redis/go-redis/v9 v9.4.0 go.opencensus.io v0.24.0 ) diff --git a/extra/rediscmd/go.mod b/extra/rediscmd/go.mod index 0790e1c8f..f27efd0be 100644 --- a/extra/rediscmd/go.mod +++ b/extra/rediscmd/go.mod @@ -7,5 +7,5 @@ replace github.com/redis/go-redis/v9 => ../.. require ( github.com/bsm/ginkgo/v2 v2.7.0 github.com/bsm/gomega v1.26.0 - github.com/redis/go-redis/v9 v9.3.1 + github.com/redis/go-redis/v9 v9.4.0 ) diff --git a/extra/redisotel/go.mod b/extra/redisotel/go.mod index 793faaf99..987953b51 100644 --- a/extra/redisotel/go.mod +++ b/extra/redisotel/go.mod @@ -7,8 +7,8 @@ replace github.com/redis/go-redis/v9 => ../.. replace github.com/redis/go-redis/extra/rediscmd/v9 => ../rediscmd require ( - github.com/redis/go-redis/extra/rediscmd/v9 v9.3.1 - github.com/redis/go-redis/v9 v9.3.1 + github.com/redis/go-redis/extra/rediscmd/v9 v9.4.0 + github.com/redis/go-redis/v9 v9.4.0 go.opentelemetry.io/otel v1.16.0 go.opentelemetry.io/otel/metric v1.16.0 go.opentelemetry.io/otel/sdk v1.16.0 diff --git a/extra/redisprometheus/go.mod b/extra/redisprometheus/go.mod index 35c4c537e..141c94e1c 100644 --- a/extra/redisprometheus/go.mod +++ b/extra/redisprometheus/go.mod @@ -6,7 +6,7 @@ replace github.com/redis/go-redis/v9 => ../.. require ( github.com/prometheus/client_golang v1.14.0 - github.com/redis/go-redis/v9 v9.3.1 + github.com/redis/go-redis/v9 v9.4.0 ) require ( diff --git a/package.json b/package.json index cfba3581f..1a690047d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redis", - "version": "9.3.1", + "version": "9.4.0", "main": "index.js", "repository": "git@github.com:redis/go-redis.git", "author": "Vladimir Mihailenco ", diff --git a/version.go b/version.go index a6c6905b0..92f498204 100644 --- a/version.go +++ b/version.go @@ -2,5 +2,5 @@ package redis // Version is the current release version. func Version() string { - return "9.3.1" + return "9.4.0" }