Skip to content

Commit 113031f

Browse files
authored
Merge branch 'master' into master
2 parents f3cc252 + beb8692 commit 113031f

File tree

94 files changed

+15114
-3086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+15114
-3086
lines changed

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: 'Run go-redis tests'
2+
description: 'Runs go-redis tests against different Redis versions and configurations'
3+
inputs:
4+
go-version:
5+
description: 'Go version to use for running tests'
6+
default: '1.23'
7+
redis-version:
8+
description: 'Redis version to test against'
9+
required: true
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Set up ${{ inputs.go-version }}
14+
uses: actions/setup-go@v5
15+
with:
16+
go-version: ${{ inputs.go-version }}
17+
18+
- name: Setup Test environment
19+
env:
20+
REDIS_VERSION: ${{ inputs.redis-version }}
21+
CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ inputs.redis-version }}"
22+
run: |
23+
set -e
24+
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
25+
if (( redis_major_version < 8 )); then
26+
echo "Using redis-stack for module tests"
27+
else
28+
echo "Using redis CE for module tests"
29+
fi
30+
31+
# Mapping of redis version to redis testing containers
32+
declare -A redis_version_mapping=(
33+
["8.0-M03"]="8.0-M04-pre"
34+
["7.4.2"]="rs-7.4.0-v2"
35+
["7.2.7"]="rs-7.2.0-v14"
36+
)
37+
38+
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
39+
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
40+
echo "REDIS_IMAGE=redis:${{ inputs.redis-version }}" >> $GITHUB_ENV
41+
echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV
42+
else
43+
echo "Version not found in the mapping."
44+
exit 1
45+
fi
46+
sleep 10 # time to settle
47+
shell: bash
48+
- name: Set up Docker Compose environment with redis ${{ inputs.redis-version }}
49+
run: docker compose --profile all up -d
50+
shell: bash
51+
- name: Run tests
52+
env:
53+
RCE_DOCKER: "true"
54+
RE_CLUSTER: "false"
55+
run: |
56+
go test \
57+
--ginkgo.skip-file="ring_test.go" \
58+
--ginkgo.skip-file="sentinel_test.go" \
59+
--ginkgo.skip-file="pubsub_test.go" \
60+
--ginkgo.skip-file="gears_commands_test.go" \
61+
--ginkgo.label-filter="!NonRedisEnterprise"
62+
shell: bash

.github/wordlist.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ACLs
2+
APIs
23
autoload
34
autoloader
45
autoloading
@@ -46,15 +47,21 @@ runtime
4647
SHA
4748
sharding
4849
SETNAME
50+
SpellCheck
4951
SSL
5052
struct
5153
stunnel
54+
SynDump
5255
TCP
5356
TLS
57+
UnstableResp
5458
uri
5559
URI
5660
url
5761
variadic
5862
RedisStack
5963
RedisGears
60-
RedisTimeseries
64+
RedisTimeseries
65+
RediSearch
66+
RawResult
67+
RawVal

.github/workflows/build.yml

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
go-version: [1.19.x, 1.20.x, 1.21.x]
20-
21-
services:
22-
redis:
23-
image: redis/redis-stack-server:edge
24-
options: >-
25-
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
26-
ports:
27-
- 6379:6379
19+
go-version: [1.21.x, 1.22.x, 1.23.x]
2820

2921
steps:
3022
- name: Set up ${{ matrix.go-version }}
@@ -37,3 +29,35 @@ jobs:
3729

3830
- name: Test
3931
run: make test
32+
33+
- name: Upload to Codecov
34+
uses: codecov/codecov-action@v5
35+
with:
36+
files: coverage.txt
37+
token: ${{ secrets.CODECOV_TOKEN }}
38+
39+
test-redis-ce:
40+
name: test-redis-ce
41+
runs-on: ubuntu-latest
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
redis-version:
46+
- "8.0-M03" # 8.0 milestone 4
47+
- "7.4.2" # should use redis stack 7.4
48+
- "7.2.7" # should redis stack 7.2
49+
go-version:
50+
- "1.22.x"
51+
- "1.23.x"
52+
53+
steps:
54+
55+
- name: Checkout code
56+
uses: actions/checkout@v4
57+
58+
- name: Run tests
59+
uses: ./.github/actions/run-tests
60+
with:
61+
go-version: ${{matrix.go-version}}
62+
redis-version: ${{ matrix.redis-version }}
63+

.github/workflows/doctests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
go-version: [ "1.18", "1.19", "1.20", "1.21" ]
28+
go-version: [ "1.21", "1.22", "1.23" ]
2929

3030
steps:
3131
- name: Set up ${{ matrix.go-version }}

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
steps:
2424
- uses: actions/checkout@v4
2525
- name: golangci-lint
26-
uses: golangci/golangci-lint-action@v4
26+
uses: golangci/golangci-lint-action@v6

.github/workflows/spellcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: Checkout
99
uses: actions/checkout@v4
1010
- name: Check Spelling
11-
uses: rojopolis/spellcheck-github-actions@0.36.0
11+
uses: rojopolis/spellcheck-github-actions@0.45.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

.github/workflows/test-redis-enterprise.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
go-version: [1.21.x]
18+
go-version: [1.23.x]
1919
re-build: ["7.4.2-54"]
2020

2121
steps:
@@ -46,7 +46,8 @@ jobs:
4646

4747
- name: Test
4848
env:
49-
RE_CLUSTER: "1"
49+
RE_CLUSTER: true
50+
REDIS_MAJOR_VERSION: 7
5051
run: |
5152
go test \
5253
--ginkgo.skip-file="ring_test.go" \

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ testdata/*
33
.idea/
44
.DS_Store
55
*.tar.gz
6-
*.dic
6+
*.dic
7+
redis8tests.sh

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## Unreleased
2+
3+
### Changed
4+
5+
* `go-redis` won't skip span creation if the parent spans is not recording. ([#2980](https://github.com/redis/go-redis/issues/2980))
6+
Users can use the OpenTelemetry sampler to control the sampling behavior.
7+
For instance, you can use the `ParentBased(NeverSample())` sampler from `go.opentelemetry.io/otel/sdk/trace` to keep
8+
a similar behavior (drop orphan spans) of `go-redis` as before.
9+
110
## [9.0.5](https://github.com/redis/go-redis/compare/v9.0.4...v9.0.5) (2023-05-29)
211

312

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
2+
export REDIS_MAJOR_VERSION := 7
23

34
test: testdeps
5+
docker start go-redis-redis-stack || docker run -d --name go-redis-redis-stack -p 6379:6379 -e REDIS_ARGS="--enable-debug-command yes --enable-module-command yes" redis/redis-stack-server:latest
46
$(eval GO_VERSION := $(shell go version | cut -d " " -f 3 | cut -d. -f2))
57
set -e; for dir in $(GO_MOD_DIRS); do \
68
if echo "$${dir}" | grep -q "./example" && [ "$(GO_VERSION)" = "19" ]; then \
@@ -14,10 +16,12 @@ test: testdeps
1416
go test ./... -short -race && \
1517
go test ./... -run=NONE -bench=. -benchmem && \
1618
env GOOS=linux GOARCH=386 go test && \
19+
go test -coverprofile=coverage.txt -covermode=atomic ./... && \
1720
go vet); \
1821
done
1922
cd internal/customvet && go build .
2023
go vet -vettool ./internal/customvet/customvet
24+
docker stop go-redis-redis-stack
2125

2226
testdeps: testdata/redis/src/redis-server
2327

@@ -31,7 +35,7 @@ build:
3135

3236
testdata/redis:
3337
mkdir -p $@
34-
wget -qO- https://download.redis.io/releases/redis-7.2.1.tar.gz | tar xvz --strip-components=1 -C $@
38+
wget -qO- https://download.redis.io/releases/redis-7.4.2.tar.gz | tar xvz --strip-components=1 -C $@
3539

3640
testdata/redis/src/redis-server: testdata/redis
3741
cd $< && make all

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![build workflow](https://github.com/redis/go-redis/actions/workflows/build.yml/badge.svg)](https://github.com/redis/go-redis/actions)
44
[![PkgGoDev](https://pkg.go.dev/badge/github.com/redis/go-redis/v9)](https://pkg.go.dev/github.com/redis/go-redis/v9?tab=doc)
55
[![Documentation](https://img.shields.io/badge/redis-documentation-informational)](https://redis.uptrace.dev/)
6+
[![codecov](https://codecov.io/github/redis/go-redis/graph/badge.svg?token=tsrCZKuSSw)](https://codecov.io/github/redis/go-redis)
67
[![Chat](https://discordapp.com/api/guilds/752070105847955518/widget.png)](https://discord.gg/rWtp5Aj)
78

89
> go-redis is brought to you by :star: [**uptrace/uptrace**](https://github.com/uptrace/uptrace).
@@ -143,9 +144,6 @@ to this specification.
143144

144145
```go
145146
import (
146-
"context"
147-
"fmt"
148-
149147
"github.com/redis/go-redis/v9"
150148
)
151149

@@ -185,6 +183,24 @@ rdb := redis.NewClient(&redis.Options{
185183
})
186184
```
187185

186+
#### Unstable RESP3 Structures for RediSearch Commands
187+
When integrating Redis with application functionalities using RESP3, it's important to note that some response structures aren't final yet. This is especially true for more complex structures like search and query results. We recommend using RESP2 when using the search and query capabilities, but we plan to stabilize the RESP3-based API-s in the coming versions. You can find more guidance in the upcoming release notes.
188+
189+
To enable unstable RESP3, set the option in your client configuration:
190+
191+
```go
192+
redis.NewClient(&redis.Options{
193+
UnstableResp3: true,
194+
})
195+
```
196+
**Note:** When UnstableResp3 mode is enabled, it's necessary to use RawResult() and RawVal() to retrieve a raw data.
197+
Since, raw response is the only option for unstable search commands Val() and Result() calls wouldn't have any affect on them:
198+
199+
```go
200+
res1, err := client.FTSearchWithArgs(ctx, "txt", "foo bar", &redis.FTSearchOptions{}).RawResult()
201+
val1 := client.FTSearchWithArgs(ctx, "txt", "foo bar", &redis.FTSearchOptions{}).RawVal()
202+
```
203+
188204
## Contributing
189205

190206
Please see [out contributing guidelines](CONTRIBUTING.md) to help us improve this library!

bench_test.go

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

278278
func newClusterScenario() *clusterScenario {
279279
return &clusterScenario{
280-
ports: []string{"8220", "8221", "8222", "8223", "8224", "8225"},
280+
ports: []string{"16600", "16601", "16602", "16603", "16604", "16605"},
281281
nodeIDs: make([]string, 6),
282282
processes: make(map[string]*redisProcess, 6),
283283
clients: make(map[string]*redis.Client, 6),

bitmap_commands.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type BitMapCmdable interface {
1616
BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd
1717
BitPosSpan(ctx context.Context, key string, bit int8, start, end int64, span string) *IntCmd
1818
BitField(ctx context.Context, key string, values ...interface{}) *IntSliceCmd
19+
BitFieldRO(ctx context.Context, key string, values ...interface{}) *IntSliceCmd
1920
}
2021

2122
func (c cmdable) GetBit(ctx context.Context, key string, offset int64) *IntCmd {
@@ -45,22 +46,19 @@ const BitCountIndexByte string = "BYTE"
4546
const BitCountIndexBit string = "BIT"
4647

4748
func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd {
48-
args := []interface{}{"bitcount", key}
49+
args := make([]any, 2, 5)
50+
args[0] = "bitcount"
51+
args[1] = key
4952
if bitCount != nil {
50-
if bitCount.Unit == "" {
51-
bitCount.Unit = "BYTE"
52-
}
53-
if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit {
54-
cmd := NewIntCmd(ctx)
55-
cmd.SetErr(errors.New("redis: invalid bitcount index"))
56-
return cmd
53+
args = append(args, bitCount.Start, bitCount.End)
54+
if bitCount.Unit != "" {
55+
if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit {
56+
cmd := NewIntCmd(ctx)
57+
cmd.SetErr(errors.New("redis: invalid bitcount index"))
58+
return cmd
59+
}
60+
args = append(args, bitCount.Unit)
5761
}
58-
args = append(
59-
args,
60-
bitCount.Start,
61-
bitCount.End,
62-
string(bitCount.Unit),
63-
)
6462
}
6563
cmd := NewIntCmd(ctx, args...)
6664
_ = c(ctx, cmd)

0 commit comments

Comments
 (0)