Skip to content

Commit 7f4c593

Browse files
committed
merge master
2 parents a118fe6 + 21ed15b commit 7f4c593

20 files changed

+380
-89
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
go-version: [1.19.x, 1.20.x, 1.21.x]
19+
go-version: [1.20.x, 1.21.x]
2020

2121
services:
2222
redis:

.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@v3
26+
uses: golangci/golangci-lint-action@v4

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
# Drafts your next Release notes as Pull Requests are merged into "master"
19-
- uses: release-drafter/release-drafter@v5
19+
- uses: release-drafter/release-drafter@v6
2020
with:
2121
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
2222
config-name: release-drafter-config.yml

.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.35.0
11+
uses: rojopolis/spellcheck-github-actions@0.36.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
go-version: [1.21.x]
19-
re-build: ["7.2.4-92"]
19+
re-build: ["7.2.4-108"]
2020

2121
steps:
2222
- name: Checkout code

bitmap_commands.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package redis
22

33
import (
44
"context"
5+
"errors"
56
)
67

78
type BitMapCmdable interface {
@@ -37,15 +38,28 @@ func (c cmdable) SetBit(ctx context.Context, key string, offset int64, value int
3738

3839
type BitCount struct {
3940
Start, End int64
41+
Unit string // BYTE(default) | BIT
4042
}
4143

44+
const BitCountIndexByte string = "BYTE"
45+
const BitCountIndexBit string = "BIT"
46+
4247
func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd {
4348
args := []interface{}{"bitcount", key}
4449
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
57+
}
4558
args = append(
4659
args,
4760
bitCount.Start,
4861
bitCount.End,
62+
string(bitCount.Unit),
4963
)
5064
}
5165
cmd := NewIntCmd(ctx, args...)

bitmap_commands_test.go

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package redis_test
2+
3+
import (
4+
. "github.com/bsm/ginkgo/v2"
5+
. "github.com/bsm/gomega"
6+
"github.com/redis/go-redis/v9"
7+
)
8+
9+
type bitCountExpected struct {
10+
Start int64
11+
End int64
12+
Expected int64
13+
}
14+
15+
var _ = Describe("BitCountBite", func() {
16+
var client *redis.Client
17+
key := "bit_count_test"
18+
19+
BeforeEach(func() {
20+
client = redis.NewClient(redisOptions())
21+
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
22+
values := []int{0, 1, 0, 0, 1, 0, 1, 0, 1, 1}
23+
for i, v := range values {
24+
cmd := client.SetBit(ctx, key, int64(i), v)
25+
Expect(cmd.Err()).NotTo(HaveOccurred())
26+
}
27+
})
28+
29+
AfterEach(func() {
30+
Expect(client.Close()).NotTo(HaveOccurred())
31+
})
32+
33+
It("bit count bite", func() {
34+
var expected = []bitCountExpected{
35+
{0, 0, 0},
36+
{0, 1, 1},
37+
{0, 2, 1},
38+
{0, 3, 1},
39+
{0, 4, 2},
40+
{0, 5, 2},
41+
{0, 6, 3},
42+
{0, 7, 3},
43+
{0, 8, 4},
44+
{0, 9, 5},
45+
}
46+
47+
for _, e := range expected {
48+
cmd := client.BitCount(ctx, key, &redis.BitCount{Start: e.Start, End: e.End, Unit: redis.BitCountIndexBit})
49+
Expect(cmd.Err()).NotTo(HaveOccurred())
50+
Expect(cmd.Val()).To(Equal(e.Expected))
51+
}
52+
})
53+
})
54+
55+
var _ = Describe("BitCountByte", func() {
56+
var client *redis.Client
57+
key := "bit_count_test"
58+
59+
BeforeEach(func() {
60+
client = redis.NewClient(redisOptions())
61+
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
62+
values := []int{0, 0, 0, 0, 0, 0, 0, 1, 1, 1}
63+
for i, v := range values {
64+
cmd := client.SetBit(ctx, key, int64(i), v)
65+
Expect(cmd.Err()).NotTo(HaveOccurred())
66+
}
67+
})
68+
69+
AfterEach(func() {
70+
Expect(client.Close()).NotTo(HaveOccurred())
71+
})
72+
73+
It("bit count byte", func() {
74+
var expected = []bitCountExpected{
75+
{0, 0, 1},
76+
{0, 1, 3},
77+
}
78+
79+
for _, e := range expected {
80+
cmd := client.BitCount(ctx, key, &redis.BitCount{Start: e.Start, End: e.End, Unit: redis.BitCountIndexByte})
81+
Expect(cmd.Err()).NotTo(HaveOccurred())
82+
Expect(cmd.Val()).To(Equal(e.Expected))
83+
}
84+
})
85+
86+
It("bit count byte with no unit specified", func() {
87+
var expected = []bitCountExpected{
88+
{0, 0, 1},
89+
{0, 1, 3},
90+
}
91+
92+
for _, e := range expected {
93+
cmd := client.BitCount(ctx, key, &redis.BitCount{Start: e.Start, End: e.End})
94+
Expect(cmd.Err()).NotTo(HaveOccurred())
95+
Expect(cmd.Val()).To(Equal(e.Expected))
96+
}
97+
})
98+
})

command.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5310,6 +5310,16 @@ type LibraryInfo struct {
53105310
LibVer *string
53115311
}
53125312

5313+
// WithLibraryName returns a valid LibraryInfo with library name only.
5314+
func WithLibraryName(libName string) LibraryInfo {
5315+
return LibraryInfo{LibName: &libName}
5316+
}
5317+
5318+
// WithLibraryVersion returns a valid LibraryInfo with library version only.
5319+
func WithLibraryVersion(libVer string) LibraryInfo {
5320+
return LibraryInfo{LibVer: &libVer}
5321+
}
5322+
53135323
// -------------------------------------------
53145324

53155325
type InfoCmd struct {

commands_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ var _ = Describe("Commands", func() {
248248

249249
// Test setting the libName
250250
libName := "go-redis"
251-
libInfo := redis.LibraryInfo{LibName: &libName}
251+
libInfo := redis.WithLibraryName(libName)
252252
setInfo := pipe.ClientSetInfo(ctx, libInfo)
253253
_, err := pipe.Exec(ctx)
254254

@@ -258,7 +258,7 @@ var _ = Describe("Commands", func() {
258258

259259
// Test setting the libVer
260260
libVer := "vX.x"
261-
libInfo = redis.LibraryInfo{LibVer: &libVer}
261+
libInfo = redis.WithLibraryVersion(libVer)
262262
setInfo = pipe.ClientSetInfo(ctx, libInfo)
263263
_, err = pipe.Exec(ctx)
264264

example/otel/config/otel-collector.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ receivers:
3030
processors:
3131
resourcedetection:
3232
detectors: ['system']
33+
cumulativetodelta:
3334
batch:
3435
send_batch_size: 10000
3536
timeout: 10s
3637

3738
exporters:
38-
logging:
39-
logLevel: debug
40-
otlp:
41-
endpoint: uptrace:14317
39+
otlp/uptrace:
40+
endpoint: http://uptrace:14317
4241
tls:
4342
insecure: true
4443
headers: { 'uptrace-dsn': 'http://project2_secret_token@localhost:14317/2' }
44+
debug:
4545

4646
service:
4747
# telemetry:
@@ -51,18 +51,18 @@ service:
5151
traces:
5252
receivers: [otlp, jaeger]
5353
processors: [batch]
54-
exporters: [otlp, logging]
54+
exporters: [otlp/uptrace]
5555
metrics:
5656
receivers: [otlp]
57-
processors: [batch]
58-
exporters: [otlp]
57+
processors: [cumulativetodelta, batch]
58+
exporters: [otlp/uptrace]
5959
metrics/hostmetrics:
6060
receivers: [hostmetrics, redis]
61-
processors: [batch, resourcedetection]
62-
exporters: [otlp]
61+
processors: [cumulativetodelta, batch, resourcedetection]
62+
exporters: [otlp/uptrace]
6363
logs:
6464
receivers: [otlp]
6565
processors: [batch]
66-
exporters: [otlp]
66+
exporters: [otlp/uptrace]
6767

6868
extensions: [health_check, pprof, zpages]

example/otel/docker-compose.yml

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

33
services:
44
clickhouse:
5-
image: clickhouse/clickhouse-server:22.10
5+
image: clickhouse/clickhouse-server:23.7
66
restart: on-failure
77
environment:
88
CLICKHOUSE_DB: uptrace
@@ -36,7 +36,7 @@ services:
3636
- '5432:5432'
3737

3838
uptrace:
39-
image: 'uptrace/uptrace:1.5.0'
39+
image: 'uptrace/uptrace:1.6.2'
4040
#image: 'uptrace/uptrace-dev:latest'
4141
restart: on-failure
4242
volumes:
@@ -51,7 +51,7 @@ services:
5151
condition: service_healthy
5252

5353
otelcol:
54-
image: otel/opentelemetry-collector-contrib:0.70.0
54+
image: otel/opentelemetry-collector-contrib:0.91.0
5555
restart: on-failure
5656
volumes:
5757
- ./config/otel-collector.yaml:/etc/otelcol-contrib/config.yaml

example/otel/go.mod

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,37 @@ replace github.com/redis/go-redis/extra/rediscmd/v9 => ../../extra/rediscmd
1111
require (
1212
github.com/redis/go-redis/extra/redisotel/v9 v9.4.0
1313
github.com/redis/go-redis/v9 v9.4.0
14-
github.com/uptrace/uptrace-go v1.16.0
15-
go.opentelemetry.io/otel v1.16.0
14+
github.com/uptrace/uptrace-go v1.21.0
15+
go.opentelemetry.io/otel v1.21.0
1616
)
1717

1818
require (
1919
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
2020
github.com/cespare/xxhash/v2 v2.2.0 // indirect
2121
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
22-
github.com/go-logr/logr v1.2.4 // indirect
22+
github.com/go-logr/logr v1.4.1 // indirect
2323
github.com/go-logr/stdr v1.2.2 // indirect
2424
github.com/golang/protobuf v1.5.3 // indirect
25-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 // indirect
25+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
2626
github.com/redis/go-redis/extra/rediscmd/v9 v9.4.0 // indirect
27-
go.opentelemetry.io/contrib/instrumentation/runtime v0.42.0 // indirect
28-
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect
29-
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0 // indirect
30-
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.39.0 // indirect
31-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 // indirect
32-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0 // indirect
33-
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0 // indirect
34-
go.opentelemetry.io/otel/metric v1.16.0 // indirect
35-
go.opentelemetry.io/otel/sdk v1.16.0 // indirect
36-
go.opentelemetry.io/otel/sdk/metric v0.39.0 // indirect
37-
go.opentelemetry.io/otel/trace v1.16.0 // indirect
38-
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
39-
golang.org/x/net v0.17.0 // indirect
40-
golang.org/x/sys v0.13.0 // indirect
41-
golang.org/x/text v0.13.0 // indirect
42-
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
43-
google.golang.org/grpc v1.56.3 // indirect
44-
google.golang.org/protobuf v1.30.0 // indirect
27+
go.opentelemetry.io/contrib/instrumentation/runtime v0.46.1 // indirect
28+
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.17.0 // indirect
29+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.43.0 // indirect
30+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.44.0 // indirect
31+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
32+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect
33+
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect
34+
go.opentelemetry.io/otel/metric v1.21.0 // indirect
35+
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
36+
go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect
37+
go.opentelemetry.io/otel/trace v1.21.0 // indirect
38+
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
39+
golang.org/x/net v0.20.0 // indirect
40+
golang.org/x/sys v0.16.0 // indirect
41+
golang.org/x/text v0.14.0 // indirect
42+
google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1 // indirect
43+
google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 // indirect
44+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect
45+
google.golang.org/grpc v1.60.1 // indirect
46+
google.golang.org/protobuf v1.32.0 // indirect
4547
)

0 commit comments

Comments
 (0)