Skip to content

Commit f1c8884

Browse files
authored
Merge branch 'master' into ndyakov/state-machine-conn
2 parents dcd8f9c + 5771fa4 commit f1c8884

File tree

9 files changed

+314
-20
lines changed

9 files changed

+314
-20
lines changed

.github/actions/run-tests/action.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,20 @@ runs:
1818
- name: Setup Test environment
1919
env:
2020
REDIS_VERSION: ${{ inputs.redis-version }}
21-
CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ inputs.redis-version }}"
2221
run: |
2322
set -e
2423
redis_version_np=$(echo "$REDIS_VERSION" | grep -oP '^\d+.\d+')
25-
24+
2625
# Mapping of redis version to redis testing containers
2726
declare -A redis_version_mapping=(
27+
["8.4.x"]="8.4-RC1-pre"
2828
["8.2.x"]="8.2.1-pre"
2929
["8.0.x"]="8.0.2"
30-
["7.4.x"]="rs-7.4.0-v5"
31-
["7.2.x"]="rs-7.2.0-v17"
3230
)
33-
31+
3432
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
3533
echo "REDIS_VERSION=${redis_version_np}" >> $GITHUB_ENV
36-
echo "REDIS_IMAGE=redis:${{ inputs.redis-version }}" >> $GITHUB_ENV
34+
echo "REDIS_IMAGE=redis:${REDIS_VERSION}" >> $GITHUB_ENV
3735
echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV
3836
else
3937
echo "Version not found in the mapping."

.github/workflows/build.yml

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

33
on:
44
push:
5-
branches: [master, v9, v9.7, v9.8, 'ndyakov/*', 'ofekshenawa/*', 'htemelski-redis/*', 'ce/*']
5+
branches: [master, v9, 'v9.*']
66
pull_request:
77
branches: [master, v9, v9.7, v9.8, 'ndyakov/*', 'ofekshenawa/*', 'htemelski-redis/*', 'ce/*']
88

@@ -18,9 +18,9 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
redis-version:
21+
- "8.4.x" # Redis CE 8.4
2122
- "8.2.x" # Redis CE 8.2
2223
- "8.0.x" # Redis CE 8.0
23-
- "7.4.x" # Redis stack 7.4
2424
go-version:
2525
- "1.23.x"
2626
- "1.24.x"
@@ -44,9 +44,9 @@ jobs:
4444
4545
# Mapping of redis version to redis testing containers
4646
declare -A redis_version_mapping=(
47+
["8.4.x"]="8.4-RC1-pre"
4748
["8.2.x"]="8.2.1-pre"
4849
["8.0.x"]="8.0.2"
49-
["7.4.x"]="rs-7.4.0-v5"
5050
)
5151
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
5252
echo "REDIS_VERSION=${redis_version_np}" >> $GITHUB_ENV
@@ -74,10 +74,9 @@ jobs:
7474
fail-fast: false
7575
matrix:
7676
redis-version:
77+
- "8.4.x" # Redis CE 8.4
7778
- "8.2.x" # Redis CE 8.2
7879
- "8.0.x" # Redis CE 8.0
79-
- "7.4.x" # Redis stack 7.4
80-
- "7.2.x" # Redis stack 7.2
8180
go-version:
8281
- "1.23.x"
8382
- "1.24.x"

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
2-
REDIS_VERSION ?= 8.2
2+
REDIS_VERSION ?= 8.4
33
RE_CLUSTER ?= false
44
RCE_DOCKER ?= true
5-
CLIENT_LIBS_TEST_IMAGE ?= redislabs/client-libs-test:8.2.1-pre
5+
CLIENT_LIBS_TEST_IMAGE ?= redislabs/client-libs-test:8.4-RC1-pre
66

77
docker.start:
88
export RE_CLUSTER=$(RE_CLUSTER) && \

docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
services:
44
redis:
5-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.2.1-pre}
5+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.4-RC1-pre}
66
platform: linux/amd64
77
container_name: redis-standalone
88
environment:
@@ -23,7 +23,7 @@ services:
2323
- all
2424

2525
osscluster:
26-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.2.1-pre}
26+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.4-RC1-pre}
2727
platform: linux/amd64
2828
container_name: redis-osscluster
2929
environment:
@@ -40,7 +40,7 @@ services:
4040
- all
4141

4242
sentinel-cluster:
43-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.2.1-pre}
43+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.4-RC1-pre}
4444
platform: linux/amd64
4545
container_name: redis-sentinel-cluster
4646
network_mode: "host"
@@ -60,7 +60,7 @@ services:
6060
- all
6161

6262
sentinel:
63-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.2.1-pre}
63+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.4-RC1-pre}
6464
platform: linux/amd64
6565
container_name: redis-sentinel
6666
depends_on:
@@ -84,7 +84,7 @@ services:
8484
- all
8585

8686
ring-cluster:
87-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.2.1-pre}
87+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.4-RC1-pre}
8888
platform: linux/amd64
8989
container_name: redis-ring-cluster
9090
environment:
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Disable Maintenance Notifications Example
2+
3+
This example demonstrates how to use the go-redis client with maintenance notifications **disabled**.
4+
5+
## What are Maintenance Notifications?
6+
7+
Maintenance notifications are a Redis Cloud feature that allows the server to notify clients about:
8+
- Planned maintenance events
9+
- Failover operations
10+
- Node migrations
11+
- Cluster topology changes
12+
13+
The go-redis client supports three modes:
14+
- **`ModeDisabled`**: Client doesn't send `CLIENT MAINT_NOTIFICATIONS ON` command
15+
- **`ModeEnabled`**: Client forcefully sends the command, interrupts connection on error
16+
- **`ModeAuto`** (default): Client tries to send the command, disables feature on error
17+
18+
## When to Disable Maintenance Notifications
19+
20+
You should disable maintenance notifications when:
21+
22+
1. **Connecting to non-Redis Cloud / Redis Enterprise instances** - Standard Redis servers don't support this feature
23+
2. **You want to handle failovers manually** - Your application has custom failover logic
24+
3. **Minimizing client-side overhead** - You want the simplest possible client behavior
25+
4. **The Redis server doesn't support the feature** - Older Redis versions or forks
26+
27+
## Usage
28+
29+
### Basic Example
30+
31+
```go
32+
import (
33+
"github.com/redis/go-redis/v9"
34+
"github.com/redis/go-redis/v9/maintnotifications"
35+
)
36+
37+
rdb := redis.NewClient(&redis.Options{
38+
Addr: "localhost:6379",
39+
40+
// Explicitly disable maintenance notifications
41+
MaintNotificationsConfig: &maintnotifications.Config{
42+
Mode: maintnotifications.ModeDisabled,
43+
},
44+
})
45+
defer rdb.Close()
46+
```
47+
48+
### Cluster Client Example
49+
50+
```go
51+
rdbCluster := redis.NewClusterClient(&redis.ClusterOptions{
52+
Addrs: []string{"localhost:7000", "localhost:7001", "localhost:7002"},
53+
54+
// Disable maintenance notifications for cluster
55+
MaintNotificationsConfig: &maintnotifications.Config{
56+
Mode: maintnotifications.ModeDisabled,
57+
},
58+
})
59+
defer rdbCluster.Close()
60+
```
61+
62+
### Default Behavior (ModeAuto)
63+
64+
If you don't specify `MaintNotifications`, the client defaults to `ModeAuto`:
65+
66+
```go
67+
// This uses ModeAuto by default
68+
rdb := redis.NewClient(&redis.Options{
69+
Addr: "localhost:6379",
70+
// MaintNotificationsConfig: nil means ModeAuto
71+
})
72+
```
73+
74+
With `ModeAuto`, the client will:
75+
1. Try to enable maintenance notifications
76+
2. If the server doesn't support it, silently disable the feature
77+
3. Continue normal operation
78+
79+
## Running the Example
80+
81+
1. Start a Redis server:
82+
```bash
83+
redis-server --port 6379
84+
```
85+
86+
2. Run the example:
87+
```bash
88+
go run main.go
89+
```
90+
91+
## Expected Output
92+
93+
```
94+
=== Example 1: Explicitly Disabled ===
95+
✓ Connected successfully (maintenance notifications disabled)
96+
✓ SET operation successful
97+
✓ GET operation successful: value1
98+
99+
=== Example 2: Default Behavior (ModeAuto) ===
100+
✓ Connected successfully (maintenance notifications auto-enabled)
101+
102+
=== Example 3: Cluster Client with Disabled Notifications ===
103+
Cluster not available (expected): ...
104+
105+
=== Example 4: Performance Comparison ===
106+
✓ 1000 SET operations (disabled): 45ms
107+
✓ 1000 SET operations (auto): 46ms
108+
109+
=== Cleanup ===
110+
✓ Database flushed
111+
112+
=== Summary ===
113+
Maintenance notifications can be disabled by setting:
114+
MaintNotificationsConfig: &maintnotifications.Config{
115+
Mode: maintnotifications.ModeDisabled,
116+
}
117+
118+
This is useful when:
119+
- Connecting to non-Redis Cloud instances
120+
- You want to handle failovers manually
121+
- You want to minimize client-side overhead
122+
- The Redis server doesn't support CLIENT MAINT_NOTIFICATIONS
123+
```
124+
125+
## Performance Impact
126+
127+
Disabling maintenance notifications has minimal performance impact. The main differences are:
128+
129+
1. **Connection Setup**: One less command (`CLIENT MAINT_NOTIFICATIONS ON`) during connection initialization
130+
2. **Runtime Overhead**: No background processing of maintenance notifications
131+
3. **Memory Usage**: Slightly lower memory footprint (no notification handlers)
132+
133+
In most cases, the performance difference is negligible (< 1%).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module github.com/redis/go-redis/example/disable-maintnotifications
2+
3+
go 1.23
4+
5+
replace github.com/redis/go-redis/v9 => ../..
6+
7+
require github.com/redis/go-redis/v9 v9.7.0
8+
9+
require (
10+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
11+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
12+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
2+
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
3+
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
4+
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
5+
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
6+
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
7+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
8+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=

0 commit comments

Comments
 (0)