Skip to content

Commit

Permalink
Merge branch 'master' into add-conn-pool-wait-stats
Browse files Browse the repository at this point in the history
  • Loading branch information
lzakharov authored Jan 9, 2024
2 parents 66f8cd4 + 531f068 commit 519bcc2
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 21 deletions.
19 changes: 15 additions & 4 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -3722,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)))
Expand Down
2 changes: 1 addition & 1 deletion example/del-keys-without-ttl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion example/hll/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/lua-scripting/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions example/otel/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/redis-bloom/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/scan-struct/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions extra/rediscensus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
2 changes: 1 addition & 1 deletion extra/rediscmd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
4 changes: 2 additions & 2 deletions extra/redisotel/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion extra/redisprometheus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
3 changes: 3 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
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.
IdentitySuffix string
}

func (opt *Options) init() {
Expand Down
3 changes: 3 additions & 0 deletions osscluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <vladimir.webdev@gmail.com>",
Expand Down
3 changes: 3 additions & 0 deletions redis.go
Original file line number Diff line number Diff line change
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.IdentitySuffix != "" {
libName = c.opt.IdentitySuffix
}
libInfo := LibraryInfo{LibName: &libName}
conn.ClientSetInfo(ctx, libInfo)
libInfo = LibraryInfo{LibVer: &libVer}
Expand Down
2 changes: 2 additions & 0 deletions ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ type RingOptions struct {
Limiter Limiter

DisableIndentity bool
IdentitySuffix string
}

func (opt *RingOptions) init() {
Expand Down Expand Up @@ -166,6 +167,7 @@ func (opt *RingOptions) clientOptions() *Options {
Limiter: opt.Limiter,

DisableIndentity: opt.DisableIndentity,
IdentitySuffix: opt.IdentitySuffix,
}
}

Expand Down
2 changes: 2 additions & 0 deletions sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type FailoverOptions struct {
TLSConfig *tls.Config

DisableIndentity bool
IdentitySuffix 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,
IdentitySuffix: opt.IdentitySuffix,
}
}

Expand Down
2 changes: 1 addition & 1 deletion sortedset_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions universal.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type UniversalOptions struct {
MasterName string

DisableIndentity bool
IdentitySuffix 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,
IdentitySuffix: o.IdentitySuffix,
}
}

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

DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
}
}

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

DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
}
}

Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package redis

// Version is the current release version.
func Version() string {
return "9.3.1"
return "9.4.0"
}

0 comments on commit 519bcc2

Please sign in to comment.