Skip to content

Commit 2b4bdfc

Browse files
authored
Merge branch 'master' into only-update-latency-in-gc-if-stale
2 parents 5dcad41 + cc9bcb0 commit 2b4bdfc

Some content is hidden

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

73 files changed

+10600
-745
lines changed

.github/wordlist.txt

Lines changed: 5 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,9 +47,11 @@ runtime
4647
SHA
4748
sharding
4849
SETNAME
50+
SpellCheck
4951
SSL
5052
struct
5153
stunnel
54+
SynDump
5255
TCP
5356
TLS
5457
uri
@@ -57,4 +60,5 @@ url
5760
variadic
5861
RedisStack
5962
RedisGears
60-
RedisTimeseries
63+
RedisTimeseries
64+
RediSearch

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
services:
2222
redis:
23-
image: redis/redis-stack-server:edge
23+
image: redis/redis-stack-server:latest
2424
options: >-
2525
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
2626
ports:
@@ -37,3 +37,9 @@ jobs:
3737

3838
- name: Test
3939
run: make test
40+
41+
- name: Upload to Codecov
42+
uses: codecov/codecov-action@v4
43+
with:
44+
files: coverage.txt
45+
token: ${{ secrets.CODECOV_TOKEN }}

.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.40.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ test: testdeps
1414
go test ./... -short -race && \
1515
go test ./... -run=NONE -bench=. -benchmem && \
1616
env GOOS=linux GOARCH=386 go test && \
17+
go test -coverprofile=coverage.txt -covermode=atomic ./... && \
1718
go vet); \
1819
done
1920
cd internal/customvet && go build .
@@ -31,7 +32,7 @@ build:
3132

3233
testdata/redis:
3334
mkdir -p $@
34-
wget -qO- https://download.redis.io/releases/redis-7.2.1.tar.gz | tar xvz --strip-components=1 -C $@
35+
wget -qO- https://download.redis.io/releases/redis-7.4-rc2.tar.gz | tar xvz --strip-components=1 -C $@
3536

3637
testdata/redis/src/redis-server: testdata/redis
3738
cd $< && make all

README.md

Lines changed: 4 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,9 @@ 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+
188189
## Contributing
189190

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

bitmap_commands.go

Lines changed: 1 addition & 0 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 {

command.go

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type Cmder interface {
4040

4141
readTimeout() *time.Duration
4242
readReply(rd *proto.Reader) error
43-
43+
readRawReply(rd *proto.Reader) error
4444
SetErr(error)
4545
Err() error
4646
}
@@ -122,11 +122,11 @@ func cmdString(cmd Cmder, val interface{}) string {
122122
//------------------------------------------------------------------------------
123123

124124
type baseCmd struct {
125-
ctx context.Context
126-
args []interface{}
127-
err error
128-
keyPos int8
129-
125+
ctx context.Context
126+
args []interface{}
127+
err error
128+
keyPos int8
129+
rawVal interface{}
130130
_readTimeout *time.Duration
131131
}
132132

@@ -197,6 +197,11 @@ func (cmd *baseCmd) setReadTimeout(d time.Duration) {
197197
cmd._readTimeout = &d
198198
}
199199

200+
func (cmd *baseCmd) readRawReply(rd *proto.Reader) (err error) {
201+
cmd.rawVal, err = rd.ReadReply()
202+
return err
203+
}
204+
200205
//------------------------------------------------------------------------------
201206

202207
type Cmd struct {
@@ -573,6 +578,10 @@ func (cmd *StatusCmd) Result() (string, error) {
573578
return cmd.val, cmd.err
574579
}
575580

581+
func (cmd *StatusCmd) Bytes() ([]byte, error) {
582+
return util.StringToBytes(cmd.val), cmd.err
583+
}
584+
576585
func (cmd *StatusCmd) String() string {
577586
return cmdString(cmd, cmd.val)
578587
}
@@ -3783,6 +3792,65 @@ func (cmd *MapStringStringSliceCmd) readReply(rd *proto.Reader) error {
37833792
return nil
37843793
}
37853794

3795+
// -----------------------------------------------------------------------
3796+
// MapStringInterfaceCmd represents a command that returns a map of strings to interface{}.
3797+
type MapMapStringInterfaceCmd struct {
3798+
baseCmd
3799+
val map[string]interface{}
3800+
}
3801+
3802+
func NewMapMapStringInterfaceCmd(ctx context.Context, args ...interface{}) *MapMapStringInterfaceCmd {
3803+
return &MapMapStringInterfaceCmd{
3804+
baseCmd: baseCmd{
3805+
ctx: ctx,
3806+
args: args,
3807+
},
3808+
}
3809+
}
3810+
3811+
func (cmd *MapMapStringInterfaceCmd) String() string {
3812+
return cmdString(cmd, cmd.val)
3813+
}
3814+
3815+
func (cmd *MapMapStringInterfaceCmd) SetVal(val map[string]interface{}) {
3816+
cmd.val = val
3817+
}
3818+
3819+
func (cmd *MapMapStringInterfaceCmd) Result() (map[string]interface{}, error) {
3820+
return cmd.val, cmd.err
3821+
}
3822+
3823+
func (cmd *MapMapStringInterfaceCmd) Val() map[string]interface{} {
3824+
return cmd.val
3825+
}
3826+
3827+
func (cmd *MapMapStringInterfaceCmd) readReply(rd *proto.Reader) (err error) {
3828+
n, err := rd.ReadArrayLen()
3829+
if err != nil {
3830+
return err
3831+
}
3832+
3833+
data := make(map[string]interface{}, n/2)
3834+
for i := 0; i < n; i += 2 {
3835+
_, err := rd.ReadArrayLen()
3836+
if err != nil {
3837+
cmd.err = err
3838+
}
3839+
key, err := rd.ReadString()
3840+
if err != nil {
3841+
cmd.err = err
3842+
}
3843+
value, err := rd.ReadString()
3844+
if err != nil {
3845+
cmd.err = err
3846+
}
3847+
data[key] = value
3848+
}
3849+
3850+
cmd.val = data
3851+
return nil
3852+
}
3853+
37863854
//-----------------------------------------------------------------------
37873855

37883856
type MapStringInterfaceSliceCmd struct {
@@ -4997,6 +5065,7 @@ type ClientInfo struct {
49975065
PSub int // number of pattern matching subscriptions
49985066
SSub int // redis version 7.0.3, number of shard channel subscriptions
49995067
Multi int // number of commands in a MULTI/EXEC context
5068+
Watch int // redis version 7.4 RC1, number of keys this client is currently watching.
50005069
QueryBuf int // qbuf, query buffer length (0 means no query pending)
50015070
QueryBufFree int // qbuf-free, free space of the query buffer (0 means the buffer is full)
50025071
ArgvMem int // incomplete arguments for the next command (already extracted from query buffer)
@@ -5149,6 +5218,8 @@ func parseClientInfo(txt string) (info *ClientInfo, err error) {
51495218
info.SSub, err = strconv.Atoi(val)
51505219
case "multi":
51515220
info.Multi, err = strconv.Atoi(val)
5221+
case "watch":
5222+
info.Watch, err = strconv.Atoi(val)
51525223
case "qbuf":
51535224
info.QueryBuf, err = strconv.Atoi(val)
51545225
case "qbuf-free":

commands.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ type Cmdable interface {
220220
ProbabilisticCmdable
221221
PubSubCmdable
222222
ScriptingFunctionsCmdable
223+
SearchCmdable
223224
SetCmdable
224225
SortedSetCmdable
225226
StringCmdable

0 commit comments

Comments
 (0)