forked from mirror/redis
gofumports
This commit is contained in:
parent
62469e4f42
commit
14c843ef89
|
@ -50,7 +50,6 @@ func (s *clusterScenario) addrs() []string {
|
||||||
func (s *clusterScenario) newClusterClientUnsafe(opt *redis.ClusterOptions) *redis.ClusterClient {
|
func (s *clusterScenario) newClusterClientUnsafe(opt *redis.ClusterOptions) *redis.ClusterClient {
|
||||||
opt.Addrs = s.addrs()
|
opt.Addrs = s.addrs()
|
||||||
return redis.NewClusterClient(opt)
|
return redis.NewClusterClient(opt)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *clusterScenario) newClusterClient(
|
func (s *clusterScenario) newClusterClient(
|
||||||
|
|
|
@ -1857,7 +1857,7 @@ func newGeoLocationSliceParser(q *GeoRadiusQuery) proto.MultiBulkParse {
|
||||||
Name: vv,
|
Name: vv,
|
||||||
})
|
})
|
||||||
case *GeoLocation:
|
case *GeoLocation:
|
||||||
//TODO: avoid copying
|
// TODO: avoid copying
|
||||||
locs = append(locs, *vv)
|
locs = append(locs, *vv)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("got %T, expected string or *GeoLocation", v)
|
return nil, fmt.Errorf("got %T, expected string or *GeoLocation", v)
|
||||||
|
|
10
commands.go
10
commands.go
|
@ -333,10 +333,12 @@ type StatefulCmdable interface {
|
||||||
ClientSetName(ctx context.Context, name string) *BoolCmd
|
ClientSetName(ctx context.Context, name string) *BoolCmd
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Cmdable = (*Client)(nil)
|
var (
|
||||||
var _ Cmdable = (*Tx)(nil)
|
_ Cmdable = (*Client)(nil)
|
||||||
var _ Cmdable = (*Ring)(nil)
|
_ Cmdable = (*Tx)(nil)
|
||||||
var _ Cmdable = (*ClusterClient)(nil)
|
_ Cmdable = (*Ring)(nil)
|
||||||
|
_ Cmdable = (*ClusterClient)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
type cmdable func(ctx context.Context, cmd Cmder) error
|
type cmdable func(ctx context.Context, cmd Cmder) error
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("server", func() {
|
Describe("server", func() {
|
||||||
|
|
||||||
It("should Auth", func() {
|
It("should Auth", func() {
|
||||||
cmds, err := client.Pipelined(ctx, func(pipe redis.Pipeliner) error {
|
cmds, err := client.Pipelined(ctx, func(pipe redis.Pipeliner) error {
|
||||||
pipe.Auth(ctx, "password")
|
pipe.Auth(ctx, "password")
|
||||||
|
@ -267,11 +266,9 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(cmd.LastKeyPos).To(Equal(int8(0)))
|
Expect(cmd.LastKeyPos).To(Equal(int8(0)))
|
||||||
Expect(cmd.StepCount).To(Equal(int8(0)))
|
Expect(cmd.StepCount).To(Equal(int8(0)))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("debugging", func() {
|
Describe("debugging", func() {
|
||||||
|
|
||||||
It("should DebugObject", func() {
|
It("should DebugObject", func() {
|
||||||
err := client.DebugObject(ctx, "foo").Err()
|
err := client.DebugObject(ctx, "foo").Err()
|
||||||
Expect(err).To(MatchError("ERR no such key"))
|
Expect(err).To(MatchError("ERR no such key"))
|
||||||
|
@ -299,11 +296,9 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(n).NotTo(BeZero())
|
Expect(n).NotTo(BeZero())
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("keys", func() {
|
Describe("keys", func() {
|
||||||
|
|
||||||
It("should Del", func() {
|
It("should Del", func() {
|
||||||
err := client.Set(ctx, "key1", "Hello", 0).Err()
|
err := client.Set(ctx, "key1", "Hello", 0).Err()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
@ -760,11 +755,9 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(type_.Err()).NotTo(HaveOccurred())
|
Expect(type_.Err()).NotTo(HaveOccurred())
|
||||||
Expect(type_.Val()).To(Equal("string"))
|
Expect(type_.Val()).To(Equal("string"))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("scanning", func() {
|
Describe("scanning", func() {
|
||||||
|
|
||||||
It("should Scan", func() {
|
It("should Scan", func() {
|
||||||
for i := 0; i < 1000; i++ {
|
for i := 0; i < 1000; i++ {
|
||||||
set := client.Set(ctx, fmt.Sprintf("key%d", i), "hello", 0)
|
set := client.Set(ctx, fmt.Sprintf("key%d", i), "hello", 0)
|
||||||
|
@ -815,11 +808,9 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(keys).NotTo(BeEmpty())
|
Expect(keys).NotTo(BeEmpty())
|
||||||
Expect(cursor).NotTo(BeZero())
|
Expect(cursor).NotTo(BeZero())
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("strings", func() {
|
Describe("strings", func() {
|
||||||
|
|
||||||
It("should Append", func() {
|
It("should Append", func() {
|
||||||
n, err := client.Exists(ctx, "key").Result()
|
n, err := client.Exists(ctx, "key").Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
@ -1253,11 +1244,9 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(strLen.Err()).NotTo(HaveOccurred())
|
Expect(strLen.Err()).NotTo(HaveOccurred())
|
||||||
Expect(strLen.Val()).To(Equal(int64(0)))
|
Expect(strLen.Val()).To(Equal(int64(0)))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("hashes", func() {
|
Describe("hashes", func() {
|
||||||
|
|
||||||
It("should HDel", func() {
|
It("should HDel", func() {
|
||||||
hSet := client.HSet(ctx, "hash", "key", "hello")
|
hSet := client.HSet(ctx, "hash", "key", "hello")
|
||||||
Expect(hSet.Err()).NotTo(HaveOccurred())
|
Expect(hSet.Err()).NotTo(HaveOccurred())
|
||||||
|
@ -1438,7 +1427,6 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(slice).To(Equal([]string{"hello1", "hello2"}))
|
Expect(slice).To(Equal([]string{"hello1", "hello2"}))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("hyperloglog", func() {
|
Describe("hyperloglog", func() {
|
||||||
|
@ -1467,7 +1455,6 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("lists", func() {
|
Describe("lists", func() {
|
||||||
|
|
||||||
It("should BLPop", func() {
|
It("should BLPop", func() {
|
||||||
rPush := client.RPush(ctx, "list1", "a", "b", "c")
|
rPush := client.RPush(ctx, "list1", "a", "b", "c")
|
||||||
Expect(rPush.Err()).NotTo(HaveOccurred())
|
Expect(rPush.Err()).NotTo(HaveOccurred())
|
||||||
|
@ -1849,11 +1836,9 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(lRange.Err()).NotTo(HaveOccurred())
|
Expect(lRange.Err()).NotTo(HaveOccurred())
|
||||||
Expect(lRange.Val()).To(Equal([]string{}))
|
Expect(lRange.Val()).To(Equal([]string{}))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("sets", func() {
|
Describe("sets", func() {
|
||||||
|
|
||||||
It("should SAdd", func() {
|
It("should SAdd", func() {
|
||||||
sAdd := client.SAdd(ctx, "set", "Hello")
|
sAdd := client.SAdd(ctx, "set", "Hello")
|
||||||
Expect(sAdd.Err()).NotTo(HaveOccurred())
|
Expect(sAdd.Err()).NotTo(HaveOccurred())
|
||||||
|
@ -2057,7 +2042,6 @@ var _ = Describe("Commands", func() {
|
||||||
sMembers := client.SMembers(ctx, "set")
|
sMembers := client.SMembers(ctx, "set")
|
||||||
Expect(sMembers.Err()).NotTo(HaveOccurred())
|
Expect(sMembers.Err()).NotTo(HaveOccurred())
|
||||||
Expect(sMembers.Val()).To(HaveLen(2))
|
Expect(sMembers.Val()).To(HaveLen(2))
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should SPopN", func() {
|
It("should SPopN", func() {
|
||||||
|
@ -2172,11 +2156,9 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(sMembers.Err()).NotTo(HaveOccurred())
|
Expect(sMembers.Err()).NotTo(HaveOccurred())
|
||||||
Expect(sMembers.Val()).To(HaveLen(5))
|
Expect(sMembers.Val()).To(HaveLen(5))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("sorted sets", func() {
|
Describe("sorted sets", func() {
|
||||||
|
|
||||||
It("should BZPopMax", func() {
|
It("should BZPopMax", func() {
|
||||||
err := client.ZAdd(ctx, "zset1", &redis.Z{
|
err := client.ZAdd(ctx, "zset1", &redis.Z{
|
||||||
Score: 1,
|
Score: 1,
|
||||||
|
@ -3400,7 +3382,6 @@ var _ = Describe("Commands", func() {
|
||||||
Member: "two",
|
Member: "two",
|
||||||
}}))
|
}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("streams", func() {
|
Describe("streams", func() {
|
||||||
|
@ -3568,13 +3549,15 @@ var _ = Describe("Commands", func() {
|
||||||
It("should XRead", func() {
|
It("should XRead", func() {
|
||||||
res, err := client.XReadStreams(ctx, "stream", "0").Result()
|
res, err := client.XReadStreams(ctx, "stream", "0").Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(res).To(Equal([]redis.XStream{{
|
Expect(res).To(Equal([]redis.XStream{
|
||||||
|
{
|
||||||
Stream: "stream",
|
Stream: "stream",
|
||||||
Messages: []redis.XMessage{
|
Messages: []redis.XMessage{
|
||||||
{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
|
{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
|
||||||
{ID: "2-0", Values: map[string]interface{}{"dos": "deux"}},
|
{ID: "2-0", Values: map[string]interface{}{"dos": "deux"}},
|
||||||
{ID: "3-0", Values: map[string]interface{}{"tres": "troix"}},
|
{ID: "3-0", Values: map[string]interface{}{"tres": "troix"}},
|
||||||
}},
|
},
|
||||||
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
_, err = client.XReadStreams(ctx, "stream", "3").Result()
|
_, err = client.XReadStreams(ctx, "stream", "3").Result()
|
||||||
|
@ -3588,12 +3571,14 @@ var _ = Describe("Commands", func() {
|
||||||
Block: 100 * time.Millisecond,
|
Block: 100 * time.Millisecond,
|
||||||
}).Result()
|
}).Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(res).To(Equal([]redis.XStream{{
|
Expect(res).To(Equal([]redis.XStream{
|
||||||
|
{
|
||||||
Stream: "stream",
|
Stream: "stream",
|
||||||
Messages: []redis.XMessage{
|
Messages: []redis.XMessage{
|
||||||
{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
|
{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
|
||||||
{ID: "2-0", Values: map[string]interface{}{"dos": "deux"}},
|
{ID: "2-0", Values: map[string]interface{}{"dos": "deux"}},
|
||||||
}},
|
},
|
||||||
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
_, err = client.XRead(ctx, &redis.XReadArgs{
|
_, err = client.XRead(ctx, &redis.XReadArgs{
|
||||||
|
@ -3615,13 +3600,15 @@ var _ = Describe("Commands", func() {
|
||||||
Streams: []string{"stream", ">"},
|
Streams: []string{"stream", ">"},
|
||||||
}).Result()
|
}).Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(res).To(Equal([]redis.XStream{{
|
Expect(res).To(Equal([]redis.XStream{
|
||||||
|
{
|
||||||
Stream: "stream",
|
Stream: "stream",
|
||||||
Messages: []redis.XMessage{
|
Messages: []redis.XMessage{
|
||||||
{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
|
{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
|
||||||
{ID: "2-0", Values: map[string]interface{}{"dos": "deux"}},
|
{ID: "2-0", Values: map[string]interface{}{"dos": "deux"}},
|
||||||
{ID: "3-0", Values: map[string]interface{}{"tres": "troix"}},
|
{ID: "3-0", Values: map[string]interface{}{"tres": "troix"}},
|
||||||
}},
|
},
|
||||||
|
},
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -3642,13 +3629,15 @@ var _ = Describe("Commands", func() {
|
||||||
Streams: []string{"stream", "0"},
|
Streams: []string{"stream", "0"},
|
||||||
}).Result()
|
}).Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(res).To(Equal([]redis.XStream{{
|
Expect(res).To(Equal([]redis.XStream{
|
||||||
|
{
|
||||||
Stream: "stream",
|
Stream: "stream",
|
||||||
Messages: []redis.XMessage{
|
Messages: []redis.XMessage{
|
||||||
{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
|
{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
|
||||||
{ID: "2-0", Values: nil},
|
{ID: "2-0", Values: nil},
|
||||||
{ID: "3-0", Values: map[string]interface{}{"tres": "troix"}},
|
{ID: "3-0", Values: map[string]interface{}{"tres": "troix"}},
|
||||||
}},
|
},
|
||||||
|
},
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -3935,7 +3924,6 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("marshaling/unmarshaling", func() {
|
Describe("marshaling/unmarshaling", func() {
|
||||||
|
|
||||||
type convTest struct {
|
type convTest struct {
|
||||||
value interface{}
|
value interface{}
|
||||||
wanted string
|
wanted string
|
||||||
|
@ -3980,11 +3968,9 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(deref(test.dest)).To(Equal(test.value))
|
Expect(deref(test.dest)).To(Equal(test.value))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("json marshaling/unmarshaling", func() {
|
Describe("json marshaling/unmarshaling", func() {
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
value := &numberStruct{Number: 42}
|
value := &numberStruct{Number: 42}
|
||||||
err := client.Set(ctx, "key", value, 0).Err()
|
err := client.Set(ctx, "key", value, 0).Err()
|
||||||
|
@ -4003,11 +3989,9 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(value.Number).To(Equal(42))
|
Expect(value.Number).To(Equal(42))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("Eval", func() {
|
Describe("Eval", func() {
|
||||||
|
|
||||||
It("returns keys and values", func() {
|
It("returns keys and values", func() {
|
||||||
vals, err := client.Eval(
|
vals, err := client.Eval(
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -4028,9 +4012,7 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(vals).To(Equal([]interface{}{int64(12), proto.RedisError("error"), "abc"}))
|
Expect(vals).To(Equal([]interface{}{int64(12), proto.RedisError("error"), "abc"}))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
type numberStruct struct {
|
type numberStruct struct {
|
||||||
|
|
|
@ -2,6 +2,10 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"log"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
"github.com/go-redis/redis/v8/redisext"
|
"github.com/go-redis/redis/v8/redisext"
|
||||||
"go.opentelemetry.io/otel/api/global"
|
"go.opentelemetry.io/otel/api/global"
|
||||||
|
@ -9,9 +13,6 @@ import (
|
||||||
traceStdout "go.opentelemetry.io/otel/exporters/trace/stdout"
|
traceStdout "go.opentelemetry.io/otel/exporters/trace/stdout"
|
||||||
"go.opentelemetry.io/otel/sdk/metric/controller/push"
|
"go.opentelemetry.io/otel/sdk/metric/controller/push"
|
||||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||||
"log"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -76,4 +77,3 @@ func main() {
|
||||||
<-time.After(5 * time.Second)
|
<-time.After(5 * time.Second)
|
||||||
span.End()
|
span.End()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,10 @@ import (
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ctx = context.Background()
|
var (
|
||||||
var rdb *redis.Client
|
ctx = context.Background()
|
||||||
|
rdb *redis.Client
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rdb = redis.NewClient(&redis.Options{
|
rdb = redis.NewClient(&redis.Options{
|
||||||
|
|
|
@ -14,7 +14,6 @@ func TestGinkgoSuite(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = Describe("CRC16", func() {
|
var _ = Describe("CRC16", func() {
|
||||||
|
|
||||||
// http://redis.io/topics/cluster-spec#keys-distribution-model
|
// http://redis.io/topics/cluster-spec#keys-distribution-model
|
||||||
It("should calculate CRC16", func() {
|
It("should calculate CRC16", func() {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
@ -29,11 +28,9 @@ var _ = Describe("CRC16", func() {
|
||||||
Expect(crc16sum(test.s)).To(Equal(test.n), "for %s", test.s)
|
Expect(crc16sum(test.s)).To(Equal(test.n), "for %s", test.s)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = Describe("HashSlot", func() {
|
var _ = Describe("HashSlot", func() {
|
||||||
|
|
||||||
It("should calculate hash slots", func() {
|
It("should calculate hash slots", func() {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
key string
|
key string
|
||||||
|
@ -70,5 +67,4 @@ var _ = Describe("HashSlot", func() {
|
||||||
Expect(Slot(test.one)).To(Equal(Slot(test.two)), "for %s <-> %s", test.one, test.two)
|
Expect(Slot(test.one)).To(Equal(Slot(test.two)), "for %s <-> %s", test.one, test.two)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -29,4 +29,3 @@ func init() {
|
||||||
metric.WithDescription("the number of connections created"),
|
metric.WithDescription("the number of connections created"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,10 @@ import (
|
||||||
"github.com/go-redis/redis/v8/internal"
|
"github.com/go-redis/redis/v8/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrClosed = errors.New("redis: client is closed")
|
var (
|
||||||
var ErrPoolTimeout = errors.New("redis: connection pool timeout")
|
ErrClosed = errors.New("redis: client is closed")
|
||||||
|
ErrPoolTimeout = errors.New("redis: connection pool timeout")
|
||||||
|
)
|
||||||
|
|
||||||
var timers = sync.Pool{
|
var timers = sync.Pool{
|
||||||
New: func() interface{} {
|
New: func() interface{} {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
type writer interface {
|
type writer interface {
|
||||||
io.Writer
|
io.Writer
|
||||||
io.ByteWriter
|
io.ByteWriter
|
||||||
//io.StringWriter
|
// io.StringWriter
|
||||||
WriteString(s string) (n int, err error)
|
WriteString(s string) (n int, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
var _ = Describe("ScanIterator", func() {
|
var _ = Describe("ScanIterator", func() {
|
||||||
var client *redis.Client
|
var client *redis.Client
|
||||||
|
|
||||||
var seed = func(n int) error {
|
seed := func(n int) error {
|
||||||
pipe := client.Pipeline()
|
pipe := client.Pipeline()
|
||||||
for i := 1; i <= n; i++ {
|
for i := 1; i <= n; i++ {
|
||||||
pipe.Set(ctx, fmt.Sprintf("K%02d", i), "x", 0).Err()
|
pipe.Set(ctx, fmt.Sprintf("K%02d", i), "x", 0).Err()
|
||||||
|
@ -21,7 +21,7 @@ var _ = Describe("ScanIterator", func() {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var extraSeed = func(n int, m int) error {
|
extraSeed := func(n int, m int) error {
|
||||||
pipe := client.Pipeline()
|
pipe := client.Pipeline()
|
||||||
for i := 1; i <= m; i++ {
|
for i := 1; i <= m; i++ {
|
||||||
pipe.Set(ctx, fmt.Sprintf("A%02d", i), "x", 0).Err()
|
pipe.Set(ctx, fmt.Sprintf("A%02d", i), "x", 0).Err()
|
||||||
|
@ -33,8 +33,8 @@ var _ = Describe("ScanIterator", func() {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var hashKey = "K_HASHTEST"
|
hashKey := "K_HASHTEST"
|
||||||
var hashSeed = func(n int) error {
|
hashSeed := func(n int) error {
|
||||||
pipe := client.Pipeline()
|
pipe := client.Pipeline()
|
||||||
for i := 1; i <= n; i++ {
|
for i := 1; i <= n; i++ {
|
||||||
pipe.HSet(ctx, hashKey, fmt.Sprintf("K%02d", i), "x").Err()
|
pipe.HSet(ctx, hashKey, fmt.Sprintf("K%02d", i), "x").Err()
|
||||||
|
|
6
ring.go
6
ring.go
|
@ -477,7 +477,7 @@ func (c *Ring) Subscribe(ctx context.Context, channels ...string) *PubSub {
|
||||||
|
|
||||||
shard, err := c.shards.GetByKey(channels[0])
|
shard, err := c.shards.GetByKey(channels[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//TODO: return PubSub with sticky error
|
// TODO: return PubSub with sticky error
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
return shard.Client.Subscribe(ctx, channels...)
|
return shard.Client.Subscribe(ctx, channels...)
|
||||||
|
@ -491,7 +491,7 @@ func (c *Ring) PSubscribe(ctx context.Context, channels ...string) *PubSub {
|
||||||
|
|
||||||
shard, err := c.shards.GetByKey(channels[0])
|
shard, err := c.shards.GetByKey(channels[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//TODO: return PubSub with sticky error
|
// TODO: return PubSub with sticky error
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
return shard.Client.PSubscribe(ctx, channels...)
|
return shard.Client.PSubscribe(ctx, channels...)
|
||||||
|
@ -672,7 +672,7 @@ func (c *Ring) generalProcessPipeline(
|
||||||
func (c *Ring) processShardPipeline(
|
func (c *Ring) processShardPipeline(
|
||||||
ctx context.Context, hash string, cmds []Cmder, tx bool,
|
ctx context.Context, hash string, cmds []Cmder, tx bool,
|
||||||
) error {
|
) error {
|
||||||
//TODO: retry?
|
// TODO: retry?
|
||||||
shard, err := c.shards.GetByName(hash)
|
shard, err := c.shards.GetByName(hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
setCmdsErr(cmds, err)
|
setCmdsErr(cmds, err)
|
||||||
|
|
|
@ -15,9 +15,11 @@ type scripter interface {
|
||||||
ScriptLoad(ctx context.Context, script string) *StringCmd
|
ScriptLoad(ctx context.Context, script string) *StringCmd
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ scripter = (*Client)(nil)
|
var (
|
||||||
var _ scripter = (*Ring)(nil)
|
_ scripter = (*Client)(nil)
|
||||||
var _ scripter = (*ClusterClient)(nil)
|
_ scripter = (*Ring)(nil)
|
||||||
|
_ scripter = (*ClusterClient)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
type Script struct {
|
type Script struct {
|
||||||
src, hash string
|
src, hash string
|
||||||
|
|
|
@ -181,9 +181,11 @@ type UniversalClient interface {
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ UniversalClient = (*Client)(nil)
|
var (
|
||||||
var _ UniversalClient = (*ClusterClient)(nil)
|
_ UniversalClient = (*Client)(nil)
|
||||||
var _ UniversalClient = (*Ring)(nil)
|
_ UniversalClient = (*ClusterClient)(nil)
|
||||||
|
_ UniversalClient = (*Ring)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
// NewUniversalClient returns a new multi client. The type of client returned depends
|
// NewUniversalClient returns a new multi client. The type of client returned depends
|
||||||
// on the following three conditions:
|
// on the following three conditions:
|
||||||
|
|
|
@ -37,5 +37,4 @@ var _ = Describe("UniversalClient", func() {
|
||||||
})
|
})
|
||||||
Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred())
|
Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue