forked from mirror/redis
Merge pull request #1882 from go-redis/chore/otel-example
chore: cleanup OpenTelemetry example
This commit is contained in:
commit
0982b38527
8
Makefile
8
Makefile
|
@ -19,8 +19,6 @@ testdata/redis:
|
||||||
testdata/redis/src/redis-server: testdata/redis
|
testdata/redis/src/redis-server: testdata/redis
|
||||||
cd $< && make all
|
cd $< && make all
|
||||||
|
|
||||||
tag:
|
fmt:
|
||||||
git tag $(VERSION)
|
gofmt -w -s ./
|
||||||
git tag extra/rediscmd/$(VERSION)
|
goimports -w -local github.com/go-redis/redis ./
|
||||||
git tag extra/redisotel/$(VERSION)
|
|
||||||
git tag extra/rediscensus/$(VERSION)
|
|
||||||
|
|
|
@ -9,11 +9,11 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
"github.com/go-redis/redis/v8/internal/hashtag"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
|
"github.com/go-redis/redis/v8/internal/hashtag"
|
||||||
)
|
)
|
||||||
|
|
||||||
type clusterScenario struct {
|
type clusterScenario struct {
|
||||||
|
|
|
@ -4,10 +4,10 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
redis "github.com/go-redis/redis/v8"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
redis "github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Cmd", func() {
|
var _ = Describe("Cmd", func() {
|
||||||
|
@ -72,7 +72,7 @@ var _ = Describe("Cmd", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("supports time.Time", func() {
|
It("supports time.Time", func() {
|
||||||
tm := time.Date(2019, 01, 01, 9, 45, 10, 222125, time.UTC)
|
tm := time.Date(2019, 1, 1, 9, 45, 10, 222125, time.UTC)
|
||||||
|
|
||||||
err := client.Set(ctx, "time_key", tm, 0).Err()
|
err := client.Set(ctx, "time_key", tm, 0).Err()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
|
@ -472,11 +472,11 @@ var _ = Describe("Commands", func() {
|
||||||
idleTime := client.ObjectIdleTime(ctx, "key")
|
idleTime := client.ObjectIdleTime(ctx, "key")
|
||||||
Expect(idleTime.Err()).NotTo(HaveOccurred())
|
Expect(idleTime.Err()).NotTo(HaveOccurred())
|
||||||
|
|
||||||
//Redis returned milliseconds/1000, which may cause ObjectIdleTime to be at a critical value,
|
// Redis returned milliseconds/1000, which may cause ObjectIdleTime to be at a critical value,
|
||||||
//should be +1s to deal with the critical value problem.
|
// should be +1s to deal with the critical value problem.
|
||||||
//if too much time (>1s) is used during command execution, it may also cause the test to fail.
|
// if too much time (>1s) is used during command execution, it may also cause the test to fail.
|
||||||
//so the ObjectIdleTime result should be <=now-start+1s
|
// so the ObjectIdleTime result should be <=now-start+1s
|
||||||
//link: https://github.com/redis/redis/blob/5b48d900498c85bbf4772c1d466c214439888115/src/object.c#L1265-L1272
|
// link: https://github.com/redis/redis/blob/5b48d900498c85bbf4772c1d466c214439888115/src/object.c#L1265-L1272
|
||||||
Expect(idleTime.Val()).To(BeNumerically("<=", time.Now().Sub(start)+time.Second))
|
Expect(idleTime.Val()).To(BeNumerically("<=", time.Now().Sub(start)+time.Second))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
### OpenTelemetry Example
|
# Example for go-redis OpenTelemetry instrumentation
|
||||||
Prints spans and metrics to the console.
|
|
||||||
#### To Run:
|
|
||||||
- `docker-compose up -d`
|
|
||||||
- `go run .`
|
|
||||||
|
|
||||||
When you're finished, be sure to run `docker-compose down` to shutdown
|
This example requires running Redis Server. You can start Redis Server using Docker:
|
||||||
the redis server.
|
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
To run this example:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
go run .
|
||||||
|
```
|
||||||
|
|
||||||
|
See [Monitoring performance and errors](https://redis.uptrace.dev/guide/tracing.html) for more
|
||||||
|
details.
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
redis-server:
|
redis-server:
|
||||||
image: redis
|
image: redis
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
- '6379:6379'
|
||||||
redis-cli:
|
redis-cli:
|
||||||
image: redis
|
image: redis
|
||||||
|
|
|
@ -2,35 +2,46 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
|
"go.opentelemetry.io/otel"
|
||||||
|
"go.opentelemetry.io/otel/codes"
|
||||||
|
"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
|
||||||
|
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||||
|
|
||||||
"github.com/go-redis/redis/extra/redisotel/v8"
|
"github.com/go-redis/redis/extra/redisotel/v8"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
"go.opentelemetry.io/otel"
|
|
||||||
"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
|
|
||||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var tracer = otel.Tracer("redisexample")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
stop := runExporter(ctx)
|
stop := configureOpentelemetry(ctx)
|
||||||
defer stop(ctx)
|
defer stop()
|
||||||
|
|
||||||
rdb := redis.NewClient(&redis.Options{
|
rdb := redis.NewClient(&redis.Options{
|
||||||
Addr: ":6379",
|
Addr: ":6379",
|
||||||
})
|
})
|
||||||
|
|
||||||
rdb.AddHook(redisotel.TracingHook{})
|
rdb.AddHook(redisotel.TracingHook{})
|
||||||
|
|
||||||
tracer := otel.Tracer("Example tracer")
|
ctx, span := tracer.Start(ctx, "handleRequest")
|
||||||
ctx, span := tracer.Start(ctx, "start-test-span")
|
defer span.End()
|
||||||
|
|
||||||
rdb.Set(ctx, "First value", "value_1", 0)
|
if err := handleRequest(ctx); err != nil {
|
||||||
|
span.RecordError(err)
|
||||||
|
span.SetStatus(codes.Error, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rdb.Set(ctx, "Second value", "value_2", 0)
|
func handleRequest(ctx context.Context) error {
|
||||||
|
if err := rdb.Set(ctx, "First value", "value_1", 0).Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := rdb.Set(ctx, "Second value", "value_2", 0).Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var group sync.WaitGroup
|
var group sync.WaitGroup
|
||||||
|
|
||||||
|
@ -40,27 +51,30 @@ func main() {
|
||||||
defer group.Done()
|
defer group.Done()
|
||||||
val := rdb.Get(ctx, "Second value").Val()
|
val := rdb.Get(ctx, "Second value").Val()
|
||||||
if val != "value_2" {
|
if val != "value_2" {
|
||||||
log.Fatalf("val was not set. expected: %s but got: %s", "value_2", val)
|
panic(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
group.Wait()
|
group.Wait()
|
||||||
|
|
||||||
rdb.Del(ctx, "First value")
|
if err := rdb.Del(ctx, "First value").Err(); err != nil {
|
||||||
rdb.Del(ctx, "Second value")
|
return err
|
||||||
|
}
|
||||||
|
if err := rdb.Del(ctx, "Second value").Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Wait some time to allow spans to export
|
return nil
|
||||||
<-time.After(5 * time.Second)
|
|
||||||
span.End()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func runExporter(ctx context.Context) func(context.Context) {
|
func configureOpentelemetry(ctx context.Context) func() {
|
||||||
provider := sdktrace.NewTracerProvider()
|
provider := sdktrace.NewTracerProvider()
|
||||||
otel.SetTracerProvider(provider)
|
otel.SetTracerProvider(provider)
|
||||||
|
|
||||||
exp, err := stdouttrace.New(stdouttrace.WithPrettyPrint())
|
exp, err := stdouttrace.New(stdouttrace.WithPrettyPrint())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
bsp := sdktrace.NewBatchSpanProcessor(exp)
|
bsp := sdktrace.NewBatchSpanProcessor(exp)
|
||||||
|
@ -68,7 +82,7 @@ func runExporter(ctx context.Context) func(context.Context) {
|
||||||
|
|
||||||
return func(ctx context.Context) {
|
return func(ctx context.Context) {
|
||||||
if err := provider.Shutdown(ctx); err != nil {
|
if err := provider.Shutdown(ctx); err != nil {
|
||||||
log.Printf("Shutdown failed: %s", err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,10 @@ package rediscensus
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"go.opencensus.io/trace"
|
||||||
|
|
||||||
"github.com/go-redis/redis/extra/rediscmd/v8"
|
"github.com/go-redis/redis/extra/rediscmd/v8"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
"go.opencensus.io/trace"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TracingHook struct{}
|
type TracingHook struct{}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build appengine
|
||||||
// +build appengine
|
// +build appengine
|
||||||
|
|
||||||
package rediscmd
|
package rediscmd
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build !appengine
|
||||||
// +build !appengine
|
// +build !appengine
|
||||||
|
|
||||||
package rediscmd
|
package rediscmd
|
||||||
|
|
|
@ -3,12 +3,13 @@ package redisotel
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/go-redis/redis/extra/rediscmd/v8"
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/codes"
|
"go.opentelemetry.io/otel/codes"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/extra/rediscmd/v8"
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tracer = otel.Tracer("github.com/go-redis/redis")
|
var tracer = otel.Tracer("github.com/go-redis/redis")
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
|
//go:build gofuzz
|
||||||
// +build gofuzz
|
// +build gofuzz
|
||||||
|
|
||||||
package fuzz
|
package fuzz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -4,6 +4,7 @@ go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cespare/xxhash/v2 v2.1.2
|
github.com/cespare/xxhash/v2 v2.1.2
|
||||||
|
github.com/daixiang0/gci v0.2.9 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
|
||||||
github.com/google/go-cmp v0.5.6 // indirect
|
github.com/google/go-cmp v0.5.6 // indirect
|
||||||
github.com/onsi/ginkgo v1.16.4
|
github.com/onsi/ginkgo v1.16.4
|
||||||
|
|
3
go.sum
3
go.sum
|
@ -1,5 +1,7 @@
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/daixiang0/gci v0.2.9 h1:iwJvwQpBZmMg31w+QQ6jsyZ54KEATn6/nfARbBNW294=
|
||||||
|
github.com/daixiang0/gci v0.2.9/go.mod h1:+4dZ7TISfSmqfAGv59ePaHfNzgGtIkHAhhdKggP1JAc=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||||
|
@ -73,6 +75,7 @@ golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20201118003311-bd56c0adb394/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
|
|
@ -3,10 +3,10 @@ package hashtag
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8/internal/rand"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8/internal/rand"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGinkgoSuite(t *testing.T) {
|
func TestGinkgoSuite(t *testing.T) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ var _ = Describe("Scan", func() {
|
||||||
Expect(Scan(&d, i{v}, i{vals[k]})).To(HaveOccurred())
|
Expect(Scan(&d, i{v}, i{vals[k]})).To(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
//success
|
// success
|
||||||
f = func(v uint64) string {
|
f = func(v uint64) string {
|
||||||
return strconv.FormatUint(v, 10)
|
return strconv.FormatUint(v, 10)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8/internal/pool"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8/internal/pool"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("ConnPool", func() {
|
var _ = Describe("ConnPool", func() {
|
||||||
|
|
|
@ -3,9 +3,10 @@ package proto_test
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8/internal/proto"
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8/internal/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testScanSliceStruct struct {
|
type testScanSliceStruct struct {
|
||||||
|
|
|
@ -6,10 +6,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8/internal/proto"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8/internal/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MyType struct{}
|
type MyType struct{}
|
||||||
|
@ -51,7 +51,7 @@ var _ = Describe("WriteBuffer", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should append time", func() {
|
It("should append time", func() {
|
||||||
tm := time.Date(2019, 01, 01, 9, 45, 10, 222125, time.UTC)
|
tm := time.Date(2019, 1, 1, 9, 45, 10, 222125, time.UTC)
|
||||||
err := wr.WriteArgs([]interface{}{tm})
|
err := wr.WriteArgs([]interface{}{tm})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build appengine
|
||||||
// +build appengine
|
// +build appengine
|
||||||
|
|
||||||
package internal
|
package internal
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build !appengine
|
||||||
// +build !appengine
|
// +build !appengine
|
||||||
|
|
||||||
package internal
|
package internal
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build appengine
|
||||||
// +build appengine
|
// +build appengine
|
||||||
|
|
||||||
package util
|
package util
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build !appengine
|
||||||
// +build !appengine
|
// +build !appengine
|
||||||
|
|
||||||
package util
|
package util
|
||||||
|
|
|
@ -3,10 +3,10 @@ package redis_test
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("ScanIterator", func() {
|
var _ = Describe("ScanIterator", func() {
|
||||||
|
|
|
@ -12,10 +12,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -295,7 +295,7 @@ func redisDir(port string) (string, error) {
|
||||||
if err := os.RemoveAll(dir); err != nil {
|
if err := os.RemoveAll(dir); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if err := os.MkdirAll(dir, 0775); err != nil {
|
if err := os.MkdirAll(dir, 0o775); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return dir, nil
|
return dir, nil
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build go1.7
|
||||||
// +build go1.7
|
// +build go1.7
|
||||||
|
|
||||||
package redis
|
package redis
|
||||||
|
|
|
@ -3,10 +3,10 @@ package redis_test
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("pipelining", func() {
|
var _ = Describe("pipelining", func() {
|
||||||
|
|
|
@ -4,10 +4,10 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("pool", func() {
|
var _ = Describe("pool", func() {
|
||||||
|
|
|
@ -7,10 +7,10 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("PubSub", func() {
|
var _ = Describe("PubSub", func() {
|
||||||
|
|
|
@ -10,10 +10,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("races", func() {
|
var _ = Describe("races", func() {
|
||||||
|
|
|
@ -8,10 +8,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
type redisHookError struct {
|
type redisHookError struct {
|
||||||
|
|
3
ring.go
3
ring.go
|
@ -12,7 +12,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cespare/xxhash/v2"
|
"github.com/cespare/xxhash/v2"
|
||||||
"github.com/dgryski/go-rendezvous"
|
rendezvous "github.com/dgryski/go-rendezvous" //nolint
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8/internal"
|
"github.com/go-redis/redis/v8/internal"
|
||||||
"github.com/go-redis/redis/v8/internal/hashtag"
|
"github.com/go-redis/redis/v8/internal/hashtag"
|
||||||
"github.com/go-redis/redis/v8/internal/pool"
|
"github.com/go-redis/redis/v8/internal/pool"
|
||||||
|
|
|
@ -9,10 +9,10 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Redis Ring", func() {
|
var _ = Describe("Redis Ring", func() {
|
||||||
|
@ -190,8 +190,8 @@ var _ = Describe("Redis Ring", func() {
|
||||||
|
|
||||||
Describe("Process hook", func() {
|
Describe("Process hook", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
//the health check leads to data race for variable "stack []string".
|
// the health check leads to data race for variable "stack []string".
|
||||||
//here, the health check time is set to 72 hours to avoid health check
|
// here, the health check time is set to 72 hours to avoid health check
|
||||||
opt := redisRingOptions()
|
opt := redisRingOptions()
|
||||||
opt.HeartbeatFrequency = 72 * time.Hour
|
opt.HeartbeatFrequency = 72 * time.Hour
|
||||||
ring = redis.NewRing(opt)
|
ring = redis.NewRing(opt)
|
||||||
|
|
|
@ -3,10 +3,10 @@ package redis_test
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Sentinel", func() {
|
var _ = Describe("Sentinel", func() {
|
||||||
|
|
3
tx.go
3
tx.go
|
@ -13,7 +13,8 @@ const TxFailedErr = proto.RedisError("redis: transaction failed")
|
||||||
// Tx implements Redis transactions as described in
|
// Tx implements Redis transactions as described in
|
||||||
// http://redis.io/topics/transactions. It's NOT safe for concurrent use
|
// http://redis.io/topics/transactions. It's NOT safe for concurrent use
|
||||||
// by multiple goroutines, because Exec resets list of watched keys.
|
// by multiple goroutines, because Exec resets list of watched keys.
|
||||||
// If you don't need WATCH it is better to use Pipeline.
|
//
|
||||||
|
// If you don't need WATCH, use Pipeline instead.
|
||||||
type Tx struct {
|
type Tx struct {
|
||||||
baseClient
|
baseClient
|
||||||
cmdable
|
cmdable
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Tx", func() {
|
var _ = Describe("Tx", func() {
|
||||||
|
|
Loading…
Reference in New Issue