mirror of https://github.com/go-redis/redis.git
Format code and fix go vet (#2696)
* run go fix ./... Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com> * run make fmt Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com> * fix go vet ./... issues * Update README.md Reorder imports with the rules defined in the Makefile as if we run `make fmt` * run gofumpt -w . * update Makefile to use gofumpt instead gofmt * increment makefile * format test * format tests Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com> --------- Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com> Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
This commit is contained in:
parent
1a7d2f4ad4
commit
e8ad794e96
4
Makefile
4
Makefile
|
@ -19,7 +19,7 @@ testdeps: testdata/redis/src/redis-server
|
|||
bench: testdeps
|
||||
go test ./... -test.run=NONE -test.bench=. -test.benchmem
|
||||
|
||||
.PHONY: all test testdeps bench
|
||||
.PHONY: all test testdeps bench fmt
|
||||
|
||||
testdata/redis:
|
||||
mkdir -p $@
|
||||
|
@ -29,7 +29,7 @@ testdata/redis/src/redis-server: testdata/redis
|
|||
cd $< && make all
|
||||
|
||||
fmt:
|
||||
gofmt -w -s ./
|
||||
gofumpt -w ./
|
||||
goimports -w -local github.com/redis/go-redis ./
|
||||
|
||||
go_mod_tidy:
|
||||
|
|
|
@ -69,8 +69,9 @@ go get github.com/redis/go-redis/v9
|
|||
```go
|
||||
import (
|
||||
"context"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"fmt"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
var ctx = context.Background()
|
||||
|
@ -125,8 +126,9 @@ go-redis also supports connecting via the [redis uri specification](https://gith
|
|||
```go
|
||||
import (
|
||||
"context"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"fmt"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
var ctx = context.Background()
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
|
||||
. "github.com/bsm/ginkgo/v2"
|
||||
. "github.com/bsm/gomega"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"github.com/redis/go-redis/v9/internal/hashtag"
|
||||
)
|
||||
|
@ -1457,7 +1458,7 @@ var _ = Describe("ClusterClient timeout", func() {
|
|||
})
|
||||
|
||||
var _ = Describe("ClusterClient ParseURL", func() {
|
||||
var cases = []struct {
|
||||
cases := []struct {
|
||||
test string
|
||||
url string
|
||||
o *redis.ClusterOptions // expected value
|
||||
|
|
|
@ -4324,7 +4324,6 @@ func (cmd *FunctionStatsCmd) readDuration(rd *proto.Reader) (time.Duration, erro
|
|||
}
|
||||
|
||||
func (cmd *FunctionStatsCmd) readCommand(rd *proto.Reader) ([]string, error) {
|
||||
|
||||
n, err := rd.ReadArrayLen()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -4341,6 +4340,7 @@ func (cmd *FunctionStatsCmd) readCommand(rd *proto.Reader) ([]string, error) {
|
|||
|
||||
return command, nil
|
||||
}
|
||||
|
||||
func (cmd *FunctionStatsCmd) readRunningScripts(rd *proto.Reader) ([]RunningScript, bool, error) {
|
||||
n, err := rd.ReadArrayLen()
|
||||
if err != nil {
|
||||
|
|
|
@ -609,7 +609,8 @@ func (info LibraryInfo) Validate() error {
|
|||
|
||||
// Hello Set the resp protocol used.
|
||||
func (c statefulCmdable) Hello(ctx context.Context,
|
||||
ver int, username, password, clientName string) *MapStringInterfaceCmd {
|
||||
ver int, username, password, clientName string,
|
||||
) *MapStringInterfaceCmd {
|
||||
args := make([]interface{}, 0, 7)
|
||||
args = append(args, "hello", ver)
|
||||
if password != "" {
|
||||
|
|
|
@ -232,7 +232,6 @@ var _ = Describe("Commands", func() {
|
|||
})
|
||||
|
||||
It("should ClientSetInfo", func() {
|
||||
|
||||
pipe := client.Pipeline()
|
||||
|
||||
// Test setting the libName
|
||||
|
@ -413,7 +412,6 @@ var _ = Describe("Commands", func() {
|
|||
})
|
||||
|
||||
It("should filter commands by ACL category", func() {
|
||||
|
||||
filter := &redis.FilterBy{
|
||||
ACLCat: "admin",
|
||||
}
|
||||
|
@ -580,7 +578,6 @@ var _ = Describe("Commands", func() {
|
|||
n, err = client.Exists(ctx, "key").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(n).To(Equal(int64(0)))
|
||||
|
||||
})
|
||||
|
||||
It("should Keys", func() {
|
||||
|
@ -727,7 +724,6 @@ var _ = Describe("Commands", func() {
|
|||
})
|
||||
|
||||
It("should PExpireTime", func() {
|
||||
|
||||
// The command returns -1 if the key exists but has no associated expiration time.
|
||||
// The command returns -2 if the key does not exist.
|
||||
pExpireTime := client.PExpireTime(ctx, "key")
|
||||
|
@ -966,7 +962,6 @@ var _ = Describe("Commands", func() {
|
|||
})
|
||||
|
||||
It("should ExpireTime", func() {
|
||||
|
||||
// The command returns -1 if the key exists but has no associated expiration time.
|
||||
// The command returns -2 if the key does not exist.
|
||||
expireTimeCmd := client.ExpireTime(ctx, "key")
|
||||
|
@ -988,7 +983,6 @@ var _ = Describe("Commands", func() {
|
|||
})
|
||||
|
||||
It("should TTL", func() {
|
||||
|
||||
// The command returns -1 if the key exists but has no associated expire
|
||||
// The command returns -2 if the key does not exist.
|
||||
ttl := client.TTL(ctx, "key")
|
||||
|
@ -2042,7 +2036,6 @@ var _ = Describe("Commands", func() {
|
|||
})
|
||||
|
||||
It("should ACL LOG", func() {
|
||||
|
||||
err := client.Do(ctx, "acl", "setuser", "test", ">test", "on", "allkeys", "+get").Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -2073,7 +2066,6 @@ var _ = Describe("Commands", func() {
|
|||
limitedLogEntries, err := client.ACLLog(ctx, 2).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(limitedLogEntries)).To(Equal(2))
|
||||
|
||||
})
|
||||
|
||||
It("should ACL LOG RESET", func() {
|
||||
|
@ -2087,7 +2079,6 @@ var _ = Describe("Commands", func() {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(logEntries)).To(Equal(0))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Describe("hashes", func() {
|
||||
|
@ -2699,7 +2690,6 @@ var _ = Describe("Commands", func() {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(key).To(Equal("list2"))
|
||||
Expect(val).To(Equal([]string{"a", "b", "c", "d"}))
|
||||
|
||||
})
|
||||
|
||||
It("should BLMPopBlocks", func() {
|
||||
|
@ -2721,7 +2711,7 @@ var _ = Describe("Commands", func() {
|
|||
case <-done:
|
||||
Fail("BLMPop is not blocked")
|
||||
case <-time.After(time.Second):
|
||||
//ok
|
||||
// ok
|
||||
}
|
||||
|
||||
_, err := client.LPush(ctx, "list_list", "a").Result()
|
||||
|
@ -2729,7 +2719,7 @@ var _ = Describe("Commands", func() {
|
|||
|
||||
select {
|
||||
case <-done:
|
||||
//ok
|
||||
// ok
|
||||
case <-time.After(time.Second):
|
||||
Fail("BLMPop is still blocked")
|
||||
}
|
||||
|
@ -4184,7 +4174,6 @@ var _ = Describe("Commands", func() {
|
|||
})
|
||||
|
||||
It("should ZMPop", func() {
|
||||
|
||||
err := client.ZAdd(ctx, "zset", redis.Z{Score: 1, Member: "one"}).Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
err = client.ZAdd(ctx, "zset", redis.Z{Score: 2, Member: "two"}).Err()
|
||||
|
@ -4256,11 +4245,9 @@ var _ = Describe("Commands", func() {
|
|||
Score: 6,
|
||||
Member: "six",
|
||||
}}))
|
||||
|
||||
})
|
||||
|
||||
It("should BZMPop", func() {
|
||||
|
||||
err := client.ZAdd(ctx, "zset", redis.Z{Score: 1, Member: "one"}).Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
err = client.ZAdd(ctx, "zset", redis.Z{Score: 2, Member: "two"}).Err()
|
||||
|
@ -4360,7 +4347,7 @@ var _ = Describe("Commands", func() {
|
|||
case <-done:
|
||||
Fail("BZMPop is not blocked")
|
||||
case <-time.After(time.Second):
|
||||
//ok
|
||||
// ok
|
||||
}
|
||||
|
||||
err := client.ZAdd(ctx, "list_list", redis.Z{Score: 1, Member: "one"}).Err()
|
||||
|
@ -4368,7 +4355,7 @@ var _ = Describe("Commands", func() {
|
|||
|
||||
select {
|
||||
case <-done:
|
||||
//ok
|
||||
// ok
|
||||
case <-time.After(time.Second):
|
||||
Fail("BZMPop is still blocked")
|
||||
}
|
||||
|
@ -6928,7 +6915,6 @@ var _ = Describe("Commands", func() {
|
|||
|
||||
close(started)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Describe("SlowLogGet", func() {
|
||||
|
@ -6949,7 +6935,6 @@ var _ = Describe("Commands", func() {
|
|||
Expect(len(result)).NotTo(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
type numberStruct struct {
|
||||
|
|
|
@ -5,10 +5,11 @@ package example_commands_test
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
func ExampleLPushLRange() {
|
||||
func ExampleClient_LPush_and_lrange() {
|
||||
ctx := context.Background()
|
||||
|
||||
rdb := redis.NewClient(&redis.Options{
|
||||
|
|
|
@ -5,10 +5,11 @@ package example_commands_test
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
func ExampleSetGet() {
|
||||
func ExampleClient_Set_and_get() {
|
||||
ctx := context.Background()
|
||||
|
||||
rdb := redis.NewClient(&redis.Options{
|
||||
|
|
|
@ -6,8 +6,9 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -6,10 +6,11 @@ import (
|
|||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
// InstrumentMetrics starts reporting OpenTelemetry Metrics.
|
||||
|
|
|
@ -29,12 +29,12 @@ var _ prometheus.Collector = (*Collector)(nil)
|
|||
// The given namespace and subsystem are used to build the fully qualified metric name,
|
||||
// i.e. "{namespace}_{subsystem}_{metric}".
|
||||
// The provided metrics are:
|
||||
// * pool_hit_total
|
||||
// * pool_miss_total
|
||||
// * pool_timeout_total
|
||||
// * pool_conn_total_current
|
||||
// * pool_conn_idle_current
|
||||
// * pool_conn_stale_total
|
||||
// - pool_hit_total
|
||||
// - pool_miss_total
|
||||
// - pool_timeout_total
|
||||
// - pool_conn_total_current
|
||||
// - pool_conn_idle_current
|
||||
// - pool_conn_stale_total
|
||||
func NewCollector(namespace, subsystem string, getter StatGetter) *Collector {
|
||||
return &Collector{
|
||||
getter: getter,
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"go/ast"
|
||||
"go/token"
|
||||
"go/types"
|
||||
|
||||
"golang.org/x/tools/go/analysis"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,8 +3,9 @@ package setval_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/redis/go-redis/internal/customvet/checks/setval"
|
||||
"golang.org/x/tools/go/analysis/analysistest"
|
||||
|
||||
"github.com/redis/go-redis/internal/customvet/checks/setval"
|
||||
)
|
||||
|
||||
func Test(t *testing.T) {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/redis/go-redis/internal/customvet/checks/setval"
|
||||
"golang.org/x/tools/go/analysis/multichecker"
|
||||
|
||||
"github.com/redis/go-redis/internal/customvet/checks/setval"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos
|
||||
// +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos
|
||||
|
||||
package pool
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build !linux && !darwin && !dragonfly && !freebsd && !netbsd && !openbsd && !solaris && !illumos
|
||||
// +build !linux,!darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!illumos
|
||||
|
||||
package pool
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos
|
||||
// +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos
|
||||
|
||||
package pool
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build appengine
|
||||
// +build appengine
|
||||
|
||||
package util
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build !appengine
|
||||
// +build !appengine
|
||||
|
||||
package util
|
||||
|
||||
|
|
|
@ -36,8 +36,10 @@ const (
|
|||
sentinelPort3 = "9128"
|
||||
)
|
||||
|
||||
var redisPort = "6380"
|
||||
var redisAddr = ":" + redisPort
|
||||
var (
|
||||
redisPort = "6380"
|
||||
redisAddr = ":" + redisPort
|
||||
)
|
||||
|
||||
var (
|
||||
sentinelAddrs = []string{":" + sentinelPort1, ":" + sentinelPort2, ":" + sentinelPort3}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build go1.7
|
||||
// +build go1.7
|
||||
|
||||
package redis
|
||||
|
||||
|
|
|
@ -310,6 +310,7 @@ func NewBFInfoCmd(ctx context.Context, args ...interface{}) *BFInfoCmd {
|
|||
func (cmd *BFInfoCmd) SetVal(val BFInfo) {
|
||||
cmd.val = val
|
||||
}
|
||||
|
||||
func (cmd *BFInfoCmd) String() string {
|
||||
return cmdString(cmd, cmd.val)
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
. "github.com/bsm/ginkgo/v2"
|
||||
. "github.com/bsm/gomega"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
|
@ -159,7 +160,6 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
|
|||
Expect(resultAdd2[0]).To(BeFalse())
|
||||
Expect(resultAdd2[1]).To(BeFalse())
|
||||
Expect(resultAdd2[2]).To(BeTrue())
|
||||
|
||||
})
|
||||
|
||||
It("should BFMExists", Label("bloom", "bfmexists"), func() {
|
||||
|
@ -424,7 +424,6 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
|
|||
Expect(result[2]).To(BeTrue())
|
||||
Expect(result[3]).To(BeFalse())
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Describe("CMS", Label("cms"), func() {
|
||||
|
@ -438,7 +437,6 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
|
|||
Expect(result[0]).To(BeEquivalentTo(int64(1)))
|
||||
Expect(result[1]).To(BeEquivalentTo(int64(2)))
|
||||
Expect(result[2]).To(BeEquivalentTo(int64(3)))
|
||||
|
||||
})
|
||||
|
||||
It("should CMSInitByDim and CMSInfo", Label("cms", "cmsinitbydim", "cmsinfo"), func() {
|
||||
|
@ -512,9 +510,7 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
|
|||
Expect(result[0]).To(BeEquivalentTo(int64(1)))
|
||||
Expect(result[1]).To(BeEquivalentTo(int64(6)))
|
||||
Expect(result[2]).To(BeEquivalentTo(int64(6)))
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Describe("TopK", Label("topk"), func() {
|
||||
|
@ -580,7 +576,6 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
|
|||
Expect(resultInfo.Depth).To(BeEquivalentTo(int64(8)))
|
||||
Expect(resultInfo.Decay).To(BeEquivalentTo(0.5))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Describe("t-digest", Label("tdigest"), func() {
|
||||
|
@ -691,7 +686,6 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
|
|||
reset, err := client.TDigestReset(ctx, "tdigest1").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(reset).To(BeEquivalentTo("OK"))
|
||||
|
||||
})
|
||||
|
||||
It("should TDigestCreateWithCompression", Label("tdigest", "tcreatewithcompression"), func() {
|
||||
|
|
|
@ -88,7 +88,6 @@ func (c cmdable) TFunctionListArgs(ctx context.Context, options *TFunctionListOp
|
|||
}
|
||||
if options.Library != "" {
|
||||
args = append(args, "LIBRARY", options.Library)
|
||||
|
||||
}
|
||||
}
|
||||
cmd := NewMapStringInterfaceSliceCmd(ctx, args...)
|
||||
|
@ -112,13 +111,11 @@ func (c cmdable) TFCallArgs(ctx context.Context, libName string, funcName string
|
|||
if options != nil {
|
||||
if options.Keys != nil {
|
||||
for _, key := range options.Keys {
|
||||
|
||||
args = append(args, key)
|
||||
}
|
||||
}
|
||||
if options.Arguments != nil {
|
||||
for _, key := range options.Arguments {
|
||||
|
||||
args = append(args, key)
|
||||
}
|
||||
}
|
||||
|
@ -144,13 +141,11 @@ func (c cmdable) TFCallASYNCArgs(ctx context.Context, libName string, funcName s
|
|||
if options != nil {
|
||||
if options.Keys != nil {
|
||||
for _, key := range options.Keys {
|
||||
|
||||
args = append(args, key)
|
||||
}
|
||||
}
|
||||
if options.Arguments != nil {
|
||||
for _, key := range options.Arguments {
|
||||
|
||||
args = append(args, key)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
. "github.com/bsm/ginkgo/v2"
|
||||
. "github.com/bsm/gomega"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
|
@ -48,7 +49,6 @@ var _ = Describe("RedisGears commands", Label("gears"), func() {
|
|||
})
|
||||
|
||||
It("should TFunctionLoad, TFunctionLoadArgs and TFunctionDelete ", Label("gears", "tfunctionload"), func() {
|
||||
|
||||
resultAdd, err := client.TFunctionLoad(ctx, libCode("lib1")).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(resultAdd).To(BeEquivalentTo("OK"))
|
||||
|
@ -56,7 +56,6 @@ var _ = Describe("RedisGears commands", Label("gears"), func() {
|
|||
resultAdd, err = client.TFunctionLoadArgs(ctx, libCodeWithConfig("lib1"), opt).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(resultAdd).To(BeEquivalentTo("OK"))
|
||||
|
||||
})
|
||||
It("should TFunctionList", Label("gears", "tfunctionlist"), func() {
|
||||
resultAdd, err := client.TFunctionLoad(ctx, libCode("lib1")).Result()
|
||||
|
@ -112,5 +111,4 @@ var _ = Describe("RedisGears commands", Label("gears"), func() {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(resultAdd).To(BeEquivalentTo("bar"))
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
@ -209,7 +209,6 @@ func (c cmdable) TSAddWithArgs(ctx context.Context, key string, timestamp interf
|
|||
}
|
||||
if options.ChunkSize != 0 {
|
||||
args = append(args, "CHUNK_SIZE", options.ChunkSize)
|
||||
|
||||
}
|
||||
if options.Encoding != "" {
|
||||
args = append(args, "ENCODING", options.Encoding)
|
||||
|
@ -251,7 +250,6 @@ func (c cmdable) TSCreateWithArgs(ctx context.Context, key string, options *TSOp
|
|||
}
|
||||
if options.ChunkSize != 0 {
|
||||
args = append(args, "CHUNK_SIZE", options.ChunkSize)
|
||||
|
||||
}
|
||||
if options.Encoding != "" {
|
||||
args = append(args, "ENCODING", options.Encoding)
|
||||
|
@ -264,7 +262,6 @@ func (c cmdable) TSCreateWithArgs(ctx context.Context, key string, options *TSOp
|
|||
args = append(args, "LABELS")
|
||||
for label, value := range options.Labels {
|
||||
args = append(args, label, value)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -285,7 +282,6 @@ func (c cmdable) TSAlter(ctx context.Context, key string, options *TSAlterOption
|
|||
}
|
||||
if options.ChunkSize != 0 {
|
||||
args = append(args, "CHUNK_SIZE", options.ChunkSize)
|
||||
|
||||
}
|
||||
if options.DuplicatePolicy != "" {
|
||||
args = append(args, "DUPLICATE_POLICY", options.DuplicatePolicy)
|
||||
|
@ -294,7 +290,6 @@ func (c cmdable) TSAlter(ctx context.Context, key string, options *TSAlterOption
|
|||
args = append(args, "LABELS")
|
||||
for label, value := range options.Labels {
|
||||
args = append(args, label, value)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +347,6 @@ func (c cmdable) TSIncrByWithArgs(ctx context.Context, key string, timestamp flo
|
|||
}
|
||||
if options.ChunkSize != 0 {
|
||||
args = append(args, "CHUNK_SIZE", options.ChunkSize)
|
||||
|
||||
}
|
||||
if options.Uncompressed {
|
||||
args = append(args, "UNCOMPRESSED")
|
||||
|
@ -361,7 +355,6 @@ func (c cmdable) TSIncrByWithArgs(ctx context.Context, key string, timestamp flo
|
|||
args = append(args, "LABELS")
|
||||
for label, value := range options.Labels {
|
||||
args = append(args, label, value)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +387,6 @@ func (c cmdable) TSDecrByWithArgs(ctx context.Context, key string, timestamp flo
|
|||
}
|
||||
if options.ChunkSize != 0 {
|
||||
args = append(args, "CHUNK_SIZE", options.ChunkSize)
|
||||
|
||||
}
|
||||
if options.Uncompressed {
|
||||
args = append(args, "UNCOMPRESSED")
|
||||
|
@ -403,7 +395,6 @@ func (c cmdable) TSDecrByWithArgs(ctx context.Context, key string, timestamp flo
|
|||
args = append(args, "LABELS")
|
||||
for label, value := range options.Labels {
|
||||
args = append(args, label, value)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
. "github.com/bsm/ginkgo/v2"
|
||||
. "github.com/bsm/gomega"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
|
@ -137,7 +138,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
resultGet, err = client.TSGet(ctx, "tsami-1").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(resultGet.Value).To(BeEquivalentTo(5))
|
||||
|
||||
})
|
||||
|
||||
It("should TSAlter", Label("timeseries", "tsalter"), func() {
|
||||
|
@ -179,7 +179,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
resultInfo, err = client.TSInfo(ctx, "1").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(resultInfo["duplicatePolicy"]).To(BeEquivalentTo("min"))
|
||||
|
||||
})
|
||||
|
||||
It("should TSCreateRule and TSDeleteRule", Label("timeseries", "tscreaterule", "tsdeleterule"), func() {
|
||||
|
@ -215,7 +214,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
resultInfo, err := client.TSInfo(ctx, "1").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(resultInfo["rules"]).To(BeEquivalentTo(map[interface{}]interface{}{}))
|
||||
|
||||
})
|
||||
|
||||
It("should TSIncrBy, TSIncrByWithArgs, TSDecrBy and TSDecrByWithArgs", Label("timeseries", "tsincrby", "tsdecrby", "tsincrbyWithArgs", "tsdecrbyWithArgs"), func() {
|
||||
|
@ -290,7 +288,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.Timestamp).To(BeEquivalentTo(2265985))
|
||||
Expect(result.Value).To(BeEquivalentTo(151))
|
||||
|
||||
})
|
||||
|
||||
It("should TSGet Latest", Label("timeseries", "tsgetlatest"), func() {
|
||||
|
@ -328,7 +325,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
result, err := client.TSInfo(ctx, "foo").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result["firstTimestamp"]).To(BeEquivalentTo(2265985))
|
||||
|
||||
})
|
||||
|
||||
It("should TSMAdd", Label("timeseries", "tsmadd"), func() {
|
||||
|
@ -346,7 +342,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
result, err := client.TSMAdd(ctx, ktvSlices).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result).To(BeEquivalentTo([]int64{1, 2, 3}))
|
||||
|
||||
})
|
||||
|
||||
It("should TSMGet and TSMGetWithArgs", Label("timeseries", "tsmget", "tsmgetWithArgs"), func() {
|
||||
|
@ -397,7 +392,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
result, err = client.TSMGetWithArgs(ctx, []string{"is_compaction=true"}, mgetOpt).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result["d"][1]).To(BeEquivalentTo([]interface{}{int64(10), 8.0}))
|
||||
|
||||
})
|
||||
|
||||
It("should TSQueryIndex", Label("timeseries", "tsqueryindex"), func() {
|
||||
|
@ -415,7 +409,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
result, err = client.TSQueryIndex(ctx, []string{"Taste=That"}).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(result)).To(BeEquivalentTo(1))
|
||||
|
||||
})
|
||||
|
||||
It("should TSDel and TSRange", Label("timeseries", "tsdel", "tsrange"), func() {
|
||||
|
@ -674,7 +667,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(resultRange[0]).To(BeEquivalentTo(redis.TSTimestampValue{Timestamp: 70, Value: 5}))
|
||||
Expect(len(resultRange)).To(BeEquivalentTo(7))
|
||||
|
||||
})
|
||||
|
||||
It("should TSMRange and TSMRangeWithArgs", Label("timeseries", "tsmrange", "tsmrangeWithArgs"), func() {
|
||||
|
@ -761,7 +753,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
result, err = client.TSMRangeWithArgs(ctx, 0, 10, []string{"team=ny"}, mrangeOpt).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result["a"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(0), 5.0}, []interface{}{int64(5), 6.0}}))
|
||||
|
||||
})
|
||||
|
||||
It("should TSMRangeWithArgs Latest", Label("timeseries", "tsmrangeWithArgs", "tsmrangelatest"), func() {
|
||||
|
@ -810,7 +801,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result["b"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(0), 4.0}, []interface{}{int64(10), 8.0}}))
|
||||
Expect(result["d"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(0), 4.0}, []interface{}{int64(10), 8.0}}))
|
||||
|
||||
})
|
||||
It("should TSMRevRange and TSMRevRangeWithArgs", Label("timeseries", "tsmrevrange", "tsmrevrangeWithArgs"), func() {
|
||||
createOpt := &redis.TSOptions{Labels: map[string]string{"Test": "This", "team": "ny"}}
|
||||
|
@ -896,7 +886,6 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
result, err = client.TSMRevRangeWithArgs(ctx, 0, 10, []string{"team=ny"}, mrangeOpt).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result["a"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(1), 10.0}, []interface{}{int64(0), 1.0}}))
|
||||
|
||||
})
|
||||
|
||||
It("should TSMRevRangeWithArgs Latest", Label("timeseries", "tsmrevrangeWithArgs", "tsmrevrangelatest"), func() {
|
||||
|
@ -945,7 +934,5 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result["b"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(10), 8.0}, []interface{}{int64(0), 4.0}}))
|
||||
Expect(result["d"][2]).To(BeEquivalentTo([]interface{}{[]interface{}{int64(10), 8.0}, []interface{}{int64(0), 4.0}}))
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
|
1
ring.go
1
ring.go
|
@ -292,7 +292,6 @@ func (c *ringSharding) SetAddrs(addrs map[string]string) {
|
|||
func (c *ringSharding) newRingShards(
|
||||
addrs map[string]string, existing *ringShards,
|
||||
) (shards *ringShards, created, unused map[string]*ringShard) {
|
||||
|
||||
shards = &ringShards{m: make(map[string]*ringShard, len(addrs))}
|
||||
created = make(map[string]*ringShard) // indexed by addr
|
||||
unused = make(map[string]*ringShard) // indexed by addr
|
||||
|
|
Loading…
Reference in New Issue