1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-12 14:21:52 +03:00

Ring instrumentantions (#1017)

* Ring instrumentantions
This commit is contained in:
Andrea Spacca
2019-04-24 08:33:36 +02:00
committed by Vladimir Mihailenco
parent 3227091087
commit 97e6ed8178
2 changed files with 30 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package redis_test
import (
"context"
"crypto/rand"
"fmt"
"net"
@ -104,6 +105,27 @@ var _ = Describe("Redis Ring", func() {
Expect(ringShard2.Info("keyspace").Val()).To(ContainSubstring("keys=100"))
})
It("propagates process for WithContext", func() {
var fromWrap []string
wrapper := func(oldProcess func(cmd redis.Cmder) error) func(cmd redis.Cmder) error {
return func(cmd redis.Cmder) error {
fromWrap = append(fromWrap, cmd.Name())
return oldProcess(cmd)
}
}
ctx := context.Background()
ring = ring.WithContext(ctx)
ring.WrapProcess(wrapper)
ring.Ping()
Expect(fromWrap).To(Equal([]string{"ping"}))
ring.Ping()
Expect(fromWrap).To(Equal([]string{"ping", "ping"}))
})
Describe("pipeline", func() {
It("distributes keys", func() {
pipe := ring.Pipeline()