Skip to content

Commit 0aa9453

Browse files
committed
Merge branch 'v9'
2 parents 52af8ba + a8a7665 commit 0aa9453

33 files changed

+1771
-1790
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Go
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [master, v9]
66
pull_request:
7-
branches: [master]
7+
branches: [master, v9]
88

99
jobs:
1010
build:

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
branches:
88
- master
99
- main
10+
- v9
1011
pull_request:
1112

1213
jobs:

CHANGELOG.md

Lines changed: 5 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -1,177 +1,6 @@
1-
## [8.11.5](https://github.com/go-redis/redis/compare/v8.11.4...v8.11.5) (2022-03-17)
1+
## v9 UNRELEASED
22

3-
4-
### Bug Fixes
5-
6-
* add missing Expire methods to Cmdable ([17e3b43](https://github.com/go-redis/redis/commit/17e3b43879d516437ada71cf9c0deac6a382ed9a))
7-
* add whitespace for avoid unlikely colisions ([7f7c181](https://github.com/go-redis/redis/commit/7f7c1817617cfec909efb13d14ad22ef05a6ad4c))
8-
* example/otel compile error ([#2028](https://github.com/go-redis/redis/issues/2028)) ([187c07c](https://github.com/go-redis/redis/commit/187c07c41bf68dc3ab280bc3a925e960bbef6475))
9-
* **extra/redisotel:** set span.kind attribute to client ([065b200](https://github.com/go-redis/redis/commit/065b200070b41e6e949710b4f9e01b50ccc60ab2))
10-
* format ([96f53a0](https://github.com/go-redis/redis/commit/96f53a0159a28affa94beec1543a62234e7f8b32))
11-
* invalid type assert in stringArg ([de6c131](https://github.com/go-redis/redis/commit/de6c131865b8263400c8491777b295035f2408e4))
12-
* rename Golang to Go ([#2030](https://github.com/go-redis/redis/issues/2030)) ([b82a2d9](https://github.com/go-redis/redis/commit/b82a2d9d4d2de7b7cbe8fcd4895be62dbcacacbc))
13-
* set timeout for WAIT command. Fixes [#1963](https://github.com/go-redis/redis/issues/1963) ([333fee1](https://github.com/go-redis/redis/commit/333fee1a8fd98a2fbff1ab187c1b03246a7eb01f))
14-
* update some argument counts in pre-allocs ([f6974eb](https://github.com/go-redis/redis/commit/f6974ebb5c40a8adf90d2cacab6dc297f4eba4c2))
15-
16-
17-
### Features
18-
19-
* Add redis v7's NX, XX, GT, LT expire variants ([e19bbb2](https://github.com/go-redis/redis/commit/e19bbb26e2e395c6e077b48d80d79e99f729a8b8))
20-
* add support for acl sentinel auth in universal client ([ab0ccc4](https://github.com/go-redis/redis/commit/ab0ccc47413f9b2a6eabc852fed5005a3ee1af6e))
21-
* add support for COPY command ([#2016](https://github.com/go-redis/redis/issues/2016)) ([730afbc](https://github.com/go-redis/redis/commit/730afbcffb93760e8a36cc06cfe55ab102b693a7))
22-
* add support for passing extra attributes added to spans ([39faaa1](https://github.com/go-redis/redis/commit/39faaa171523834ba527c9789710c4fde87f5a2e))
23-
* add support for time.Duration write and scan ([2f1b74e](https://github.com/go-redis/redis/commit/2f1b74e20cdd7719b2aecf0768d3e3ae7c3e781b))
24-
* **redisotel:** ability to override TracerProvider ([#1998](https://github.com/go-redis/redis/issues/1998)) ([bf8d4aa](https://github.com/go-redis/redis/commit/bf8d4aa60c00366cda2e98c3ddddc8cf68507417))
25-
* set net.peer.name and net.peer.port in otel example ([69bf454](https://github.com/go-redis/redis/commit/69bf454f706204211cd34835f76b2e8192d3766d))
26-
27-
28-
29-
## [8.11.4](https://github.com/go-redis/redis/compare/v8.11.3...v8.11.4) (2021-10-04)
30-
31-
32-
### Features
33-
34-
* add acl auth support for sentinels ([f66582f](https://github.com/go-redis/redis/commit/f66582f44f3dc3a4705a5260f982043fde4aa634))
35-
* add Cmd.{String,Int,Float,Bool}Slice helpers and an example ([5d3d293](https://github.com/go-redis/redis/commit/5d3d293cc9c60b90871e2420602001463708ce24))
36-
* add SetVal method for each command ([168981d](https://github.com/go-redis/redis/commit/168981da2d84ee9e07d15d3e74d738c162e264c4))
37-
38-
39-
40-
## v8.11
41-
42-
- Remove OpenTelemetry metrics.
43-
- Supports more redis commands and options.
44-
45-
## v8.10
46-
47-
- Removed extra OpenTelemetry spans from go-redis core. Now go-redis instrumentation only adds a
48-
single span with a Redis command (instead of 4 spans). There are multiple reasons behind this
49-
decision:
50-
51-
- Traces become smaller and less noisy.
52-
- It may be costly to process those 3 extra spans for each query.
53-
- go-redis no longer depends on OpenTelemetry.
54-
55-
Eventually we hope to replace the information that we no longer collect with OpenTelemetry
56-
Metrics.
57-
58-
## v8.9
59-
60-
- Changed `PubSub.Channel` to only rely on `Ping` result. You can now use `WithChannelSize`,
61-
`WithChannelHealthCheckInterval`, and `WithChannelSendTimeout` to override default settings.
62-
63-
## v8.8
64-
65-
- To make updating easier, extra modules now have the same version as go-redis does. That means that
66-
you need to update your imports:
67-
68-
```
69-
github.com/go-redis/redis/extra/redisotel -> github.com/go-redis/redis/extra/redisotel/v8
70-
github.com/go-redis/redis/extra/rediscensus -> github.com/go-redis/redis/extra/rediscensus/v8
71-
```
72-
73-
## v8.5
74-
75-
- [knadh](https://github.com/knadh) contributed long-awaited ability to scan Redis Hash into a
76-
struct:
77-
78-
```go
79-
err := rdb.HGetAll(ctx, "hash").Scan(&data)
80-
81-
err := rdb.MGet(ctx, "key1", "key2").Scan(&data)
82-
```
83-
84-
- Please check [redismock](https://github.com/go-redis/redismock) by
85-
[monkey92t](https://github.com/monkey92t) if you are looking for mocking Redis Client.
86-
87-
## v8
88-
89-
- All commands require `context.Context` as a first argument, e.g. `rdb.Ping(ctx)`. If you are not
90-
using `context.Context` yet, the simplest option is to define global package variable
91-
`var ctx = context.TODO()` and use it when `ctx` is required.
92-
93-
- Full support for `context.Context` canceling.
94-
95-
- Added `redis.NewFailoverClusterClient` that supports routing read-only commands to a slave node.
96-
97-
- Added `redisext.OpenTemetryHook` that adds
98-
[Redis OpenTelemetry instrumentation](https://redis.uptrace.dev/tracing/).
99-
100-
- Redis slow log support.
101-
102-
- Ring uses Rendezvous Hashing by default which provides better distribution. You need to move
103-
existing keys to a new location or keys will be inaccessible / lost. To use old hashing scheme:
104-
105-
```go
106-
import "github.com/golang/groupcache/consistenthash"
107-
108-
ring := redis.NewRing(&redis.RingOptions{
109-
NewConsistentHash: func() {
110-
return consistenthash.New(100, crc32.ChecksumIEEE)
111-
},
112-
})
113-
```
114-
115-
- `ClusterOptions.MaxRedirects` default value is changed from 8 to 3.
116-
- `Options.MaxRetries` default value is changed from 0 to 3.
117-
118-
- `Cluster.ForEachNode` is renamed to `ForEachShard` for consistency with `Ring`.
119-
120-
## v7.3
121-
122-
- New option `Options.Username` which causes client to use `AuthACL`. Be aware if your connection
123-
URL contains username.
124-
125-
## v7.2
126-
127-
- Existing `HMSet` is renamed to `HSet` and old deprecated `HMSet` is restored for Redis 3 users.
128-
129-
## v7.1
130-
131-
- Existing `Cmd.String` is renamed to `Cmd.Text`. New `Cmd.String` implements `fmt.Stringer`
132-
interface.
133-
134-
## v7
135-
136-
- _Important_. Tx.Pipeline now returns a non-transactional pipeline. Use Tx.TxPipeline for a
137-
transactional pipeline.
138-
- WrapProcess is replaced with more convenient AddHook that has access to context.Context.
139-
- WithContext now can not be used to create a shallow copy of the client.
140-
- New methods ProcessContext, DoContext, and ExecContext.
141-
- Client respects Context.Deadline when setting net.Conn deadline.
142-
- Client listens on Context.Done while waiting for a connection from the pool and returns an error
143-
when context context is cancelled.
144-
- Add PubSub.ChannelWithSubscriptions that sends `*Subscription` in addition to `*Message` to allow
145-
detecting reconnections.
146-
- `time.Time` is now marshalled in RFC3339 format. `rdb.Get("foo").Time()` helper is added to parse
147-
the time.
148-
- `SetLimiter` is removed and added `Options.Limiter` instead.
149-
- `HMSet` is deprecated as of Redis v4.
150-
151-
## v6.15
152-
153-
- Cluster and Ring pipelines process commands for each node in its own goroutine.
154-
155-
## 6.14
156-
157-
- Added Options.MinIdleConns.
158-
- Added Options.MaxConnAge.
159-
- PoolStats.FreeConns is renamed to PoolStats.IdleConns.
160-
- Add Client.Do to simplify creating custom commands.
161-
- Add Cmd.String, Cmd.Int, Cmd.Int64, Cmd.Uint64, Cmd.Float64, and Cmd.Bool helpers.
162-
- Lower memory usage.
163-
164-
## v6.13
165-
166-
- Ring got new options called `HashReplicas` and `Hash`. It is recommended to set
167-
`HashReplicas = 1000` for better keys distribution between shards.
168-
- Cluster client was optimized to use much less memory when reloading cluster state.
169-
- PubSub.ReceiveMessage is re-worked to not use ReceiveTimeout so it does not lose data when timeout
170-
occurres. In most cases it is recommended to use PubSub.Channel instead.
171-
- Dialer.KeepAlive is set to 5 minutes by default.
172-
173-
## v6.12
174-
175-
- ClusterClient got new option called `ClusterSlots` which allows to build cluster of normal Redis
176-
Servers that don't have cluster mode enabled. See
177-
https://godoc.org/github.com/go-redis/redis#example-NewClusterClient--ManualSetup
3+
- Added support for [RESP3](https://github.com/antirez/RESP3/blob/master/spec.md) protocol.
4+
- Removed `Pipeline.Close` since there is no real need to explicitly manage pipeline resources.
5+
`Pipeline.Discard` is still available if you want to reset commands for some reason.
6+
- Replaced `*redis.Z` with `redis.Z` since it is small enough to be passed as value.

bench_decode_test.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ type ClientStub struct {
1818
resp []byte
1919
}
2020

21+
var initHello = []byte("%1\r\n+proto\r\n:3\r\n")
22+
2123
func NewClientStub(resp []byte) *ClientStub {
2224
stub := &ClientStub{
2325
resp: resp,
2426
}
27+
2528
stub.Cmdable = NewClient(&Options{
2629
PoolSize: 128,
2730
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
28-
return stub.stubConn(), nil
31+
return stub.stubConn(initHello), nil
2932
},
3033
})
3134
return stub
@@ -40,7 +43,7 @@ func NewClusterClientStub(resp []byte) *ClientStub {
4043
PoolSize: 128,
4144
Addrs: []string{"127.0.0.1:6379"},
4245
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
43-
return stub.stubConn(), nil
46+
return stub.stubConn(initHello), nil
4447
},
4548
ClusterSlots: func(_ context.Context) ([]ClusterSlot, error) {
4649
return []ClusterSlot{
@@ -65,18 +68,27 @@ func NewClusterClientStub(resp []byte) *ClientStub {
6568
return stub
6669
}
6770

68-
func (c *ClientStub) stubConn() *ConnStub {
71+
func (c *ClientStub) stubConn(init []byte) *ConnStub {
6972
return &ConnStub{
73+
init: init,
7074
resp: c.resp,
7175
}
7276
}
7377

7478
type ConnStub struct {
79+
init []byte
7580
resp []byte
7681
pos int
7782
}
7883

7984
func (c *ConnStub) Read(b []byte) (n int, err error) {
85+
// Return conn.init()
86+
if len(c.init) > 0 {
87+
n = copy(b, c.init)
88+
c.init = c.init[n:]
89+
return n, nil
90+
}
91+
8092
if len(c.resp) == 0 {
8193
return 0, io.EOF
8294
}

bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func BenchmarkZAdd(b *testing.B) {
223223

224224
b.RunParallel(func(pb *testing.PB) {
225225
for pb.Next() {
226-
err := client.ZAdd(ctx, "key", &redis.Z{
226+
err := client.ZAdd(ctx, "key", redis.Z{
227227
Score: float64(1),
228228
Member: "hello",
229229
}).Err()

cluster.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,6 @@ func (c *ClusterClient) process(ctx context.Context, cmd Cmder) error {
795795
_ = pipe.Process(ctx, NewCmd(ctx, "asking"))
796796
_ = pipe.Process(ctx, cmd)
797797
_, lastErr = pipe.Exec(ctx)
798-
_ = pipe.Close()
799798
ask = false
800799
} else {
801800
lastErr = node.Client.Process(ctx, cmd)
@@ -1406,12 +1405,7 @@ func (c *ClusterClient) txPipelineReadQueued(
14061405
return err
14071406
}
14081407

1409-
switch line[0] {
1410-
case proto.ErrorReply:
1411-
return proto.ParseErrorReply(line)
1412-
case proto.ArrayReply:
1413-
// ok
1414-
default:
1408+
if line[0] != proto.RespArray {
14151409
return fmt.Errorf("redis: expected '*', but got line %q", line)
14161410
}
14171411

cluster_test.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,7 @@ var _ = Describe("ClusterClient", func() {
515515
pipe = client.Pipeline().(*redis.Pipeline)
516516
})
517517

518-
AfterEach(func() {
519-
Expect(pipe.Close()).NotTo(HaveOccurred())
520-
})
518+
AfterEach(func() {})
521519

522520
assertPipeline()
523521
})
@@ -527,9 +525,7 @@ var _ = Describe("ClusterClient", func() {
527525
pipe = client.TxPipeline().(*redis.Pipeline)
528526
})
529527

530-
AfterEach(func() {
531-
Expect(pipe.Close()).NotTo(HaveOccurred())
532-
})
528+
AfterEach(func() {})
533529

534530
assertPipeline()
535531
})
@@ -1182,16 +1178,17 @@ var _ = Describe("ClusterClient with unavailable Cluster", func() {
11821178
var client *redis.ClusterClient
11831179

11841180
BeforeEach(func() {
1185-
for _, node := range cluster.clients {
1186-
err := node.ClientPause(ctx, 5*time.Second).Err()
1187-
Expect(err).NotTo(HaveOccurred())
1188-
}
1189-
11901181
opt := redisClusterOptions()
11911182
opt.ReadTimeout = 250 * time.Millisecond
11921183
opt.WriteTimeout = 250 * time.Millisecond
11931184
opt.MaxRedirects = 1
11941185
client = cluster.newClusterClientUnstable(opt)
1186+
Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred())
1187+
1188+
for _, node := range cluster.clients {
1189+
err := node.ClientPause(ctx, 5*time.Second).Err()
1190+
Expect(err).NotTo(HaveOccurred())
1191+
}
11951192
})
11961193

11971194
AfterEach(func() {

0 commit comments

Comments
 (0)