From cb76e0eae757710fc4dd3af8940c5a2284f7a28d Mon Sep 17 00:00:00 2001 From: Miroslav Stoklasa Date: Tue, 26 Mar 2019 14:18:22 +0100 Subject: [PATCH] Trying to patch it to remove dependencty on go modules --- README.md | 120 +----- action.go | 4 +- action_test.go | 2 +- bench/bench_test.go | 269 ------------ bench/go.mod | 12 - bench/go.sum | 18 - cluster.go | 4 +- cluster_stub_test.go | 2 +- cluster_topo.go | 4 +- cluster_topo_test.go | 4 +- gm-patch.sh | 17 + go.mod | 8 - go.sum | 8 - pool.go | 2 +- pubsub.go | 4 +- pubsub_stub.go | 4 +- pubsub_stub_test.go | 2 +- radix.go | 2 +- resp/resp2/resp.go | 4 +- resp/resp2/resp_test.go | 2 +- scanner.go | 2 +- scanner_test.go | 125 ------ stream.go | 6 +- stream_test.go | 913 ---------------------------------------- stub.go | 4 +- stub_test.go | 2 +- 26 files changed, 45 insertions(+), 1499 deletions(-) delete mode 100644 bench/bench_test.go delete mode 100644 bench/go.mod delete mode 100644 bench/go.sum create mode 100755 gm-patch.sh delete mode 100644 go.mod delete mode 100644 go.sum delete mode 100644 scanner_test.go delete mode 100644 stream_test.go diff --git a/README.md b/README.md index 26fa2513..8c57ad15 100644 --- a/README.md +++ b/README.md @@ -1,123 +1,5 @@ # Radix -[![Build Status](https://travis-ci.org/mediocregopher/radix.svg)](https://travis-ci.org/mediocregopher/radix) -[![Go Report Card](https://goreportcard.com/badge/github.com/mediocregopher/radix/v3)](https://goreportcard.com/report/github.com/mediocregopher/radix/v3) -[![GoDoc](https://godoc.org/github.com/mediocregopher/radix?status.svg)][godoc] +forked and patched from github.com/mediocregopher/radix to overcome issues with golang modules -Radix is a full-featured [Redis][redis] client for Go. See the [GoDoc][godoc] -for documentation and general usage examples. -This is the third revision of this project, the previous one has been deprecated -but can be found [here](https://github.com/mediocregopher/radix.v2). - -**This project's name was recently changed from `radix.v3` to `radix`, to -account for go's new [module][module] system. As long as you are using the -latest update of your major go version (1.9.7+, 1.10.3+, 1.11+) the module-aware -go get should work correctly with the new import path.** - -**I'm sorry to anyone for whom this change broke their build, I tried very hard -to not have to do it, but ultimately it was the only way that made sense for the -future. Hopefully the only thing needed to fix the breakage is to change the -import paths and re-run 'go get'.** - -## Installation and Usage - -[Module][module]-aware mode: - - go get github.com/mediocregopher/radix/v3 - // import github.com/mediocregopher/radix/v3 - -Legacy GOPATH mode: - - go get github.com/mediocregopher/radix - // import github.com/mediocregopher/radix - -## Testing - - # requires a redis server running on 127.0.0.1:6379 - go test github.com/mediocregopher/radix/v3 - -## Features - -* Standard print-like API which supports all current and future redis commands. - -* Support for using an io.Reader as a command argument and writing responses to - an io.Writer, as well as marshaling/unmarshaling command arguments from - structs. - -* Connection pooling, which takes advantage of implicit pipelining to reduce - system calls. - -* Helpers for [EVAL][eval], [SCAN][scan], and manual [pipelining][pipelining]. - -* Support for [pubsub][pubsub], as well as persistent pubsub wherein if a - connection is lost a new one transparently replaces it. - -* Full support for [sentinel][sentinel] and [cluster][cluster]. - -* Nearly all important types are interfaces, allowing for custom implementations - of nearly anything. - -## Benchmarks - -Thanks to a huge amount of work put in by @nussjustin, and inspiration from the -[redispipe][redispipe] project and @funny-falcon, radix/v3 is significantly -faster than most redis drivers, including redigo, for normal parallel workloads, -and is pretty comparable for serial workloads. - -Benchmarks can be run from the bench folder. The following results were obtained -by running the benchmarks with `-cpu` set to 32 and 64, on a 32 core machine, -with the redis server on a separate machine. See [this thread][bench_thread] -for more details. - -Some of radix's results are not included below because they use a non-default -configuration. - -[bench_thread]: https://github.com/mediocregopher/radix/issues/67#issuecomment-465060960 - - -``` -# go get rsc.io/benchstat -# cd bench -# go test -v -run=XXX -bench=ParallelGetSet -cpu 32 -cpu 64 -benchmem . >/tmp/radix.stat -# benchstat radix.stat -name time/op -ParallelGetSet/radix/default-32 2.15µs ± 0% <--- The good stuff -ParallelGetSet/radix/default-64 2.05µs ± 0% <--- The better stuff -ParallelGetSet/redigo-32 27.9µs ± 0% -ParallelGetSet/redigo-64 28.5µs ± 0% -ParallelGetSet/redispipe-32 2.02µs ± 0% -ParallelGetSet/redispipe-64 1.71µs ± 0% - -name alloc/op -ParallelGetSet/radix/default-32 72.0B ± 0% -ParallelGetSet/radix/default-64 84.0B ± 0% -ParallelGetSet/redigo-32 119B ± 0% -ParallelGetSet/redigo-64 120B ± 0% -ParallelGetSet/redispipe-32 168B ± 0% -ParallelGetSet/redispipe-64 172B ± 0% - -name allocs/op -ParallelGetSet/radix/default-32 4.00 ± 0% -ParallelGetSet/radix/default-64 4.00 ± 0% -ParallelGetSet/redigo-32 6.00 ± 0% -ParallelGetSet/redigo-64 6.00 ± 0% -ParallelGetSet/redispipe-32 8.00 ± 0% -ParallelGetSet/redispipe-64 8.00 ± 0% -``` - -## Copyright and licensing - -Unless otherwise noted, the source files are distributed under the *MIT License* -found in the LICENSE.txt file. - -[redis]: http://redis.io -[godoc]: https://godoc.org/github.com/mediocregopher/radix -[eval]: https://redis.io/commands/eval -[scan]: https://redis.io/commands/scan -[pipelining]: https://redis.io/topics/pipelining -[pubsub]: https://redis.io/topics/pubsub -[sentinel]: http://redis.io/topics/sentinel -[cluster]: http://redis.io/topics/cluster-spec -[module]: https://github.com/golang/go/wiki/Modules -[redispipe]: https://github.com/joomcode/redispipe diff --git a/action.go b/action.go index 15d8927c..53e07e97 100644 --- a/action.go +++ b/action.go @@ -11,8 +11,8 @@ import ( "strings" "sync" - "github.com/mediocregopher/radix/v3/resp" - "github.com/mediocregopher/radix/v3/resp/resp2" + "github.com/groupme/radix/resp" + "github.com/groupme/radix/resp/resp2" ) // Action can perform one or more tasks using a Conn diff --git a/action_test.go b/action_test.go index 512f81cd..8653c149 100644 --- a/action_test.go +++ b/action_test.go @@ -6,7 +6,7 @@ import ( "fmt" . "testing" - "github.com/mediocregopher/radix/v3/resp/resp2" + "github.com/groupme/radix/resp/resp2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/bench/bench_test.go b/bench/bench_test.go deleted file mode 100644 index bc8f8aa6..00000000 --- a/bench/bench_test.go +++ /dev/null @@ -1,269 +0,0 @@ -package bench - -import ( - "context" - "errors" - "runtime" - "strings" - . "testing" - "time" - - redigo "github.com/gomodule/redigo/redis" - redispipe "github.com/joomcode/redispipe/redis" - redispipeconn "github.com/joomcode/redispipe/redisconn" - "github.com/mediocregopher/radix/v3" -) - -func newRedigo() redigo.Conn { - c, err := redigo.Dial("tcp", "127.0.0.1:6379") - if err != nil { - panic(err) - } - return c -} - -func newRedisPipe(writePause time.Duration) redispipe.Sync { - pipe, err := redispipeconn.Connect(context.Background(), "127.0.0.1:6379", redispipeconn.Opts{ - Logger: redispipeconn.NoopLogger{}, - WritePause: writePause, - }) - if err != nil { - panic(err) - } - return redispipe.Sync{S: pipe} -} - -func radixGetSet(client radix.Client, key, val string) error { - if err := client.Do(radix.Cmd(nil, "SET", key, val)); err != nil { - return err - } - var out string - if err := client.Do(radix.Cmd(&out, "GET", key)); err != nil { - return err - } else if out != val { - return errors.New("got wrong value") - } - return nil -} - -func BenchmarkSerialGetSet(b *B) { - b.Run("radix", func(b *B) { - rad, err := radix.Dial("tcp", "127.0.0.1:6379") - if err != nil { - b.Fatal(err) - } - defer rad.Close() - // avoid overhead of converting from radix.Conn to radix.Client on each loop iteration - client := radix.Client(rad) - b.ResetTimer() - for i := 0; i < b.N; i++ { - if err := radixGetSet(client, "foo", "bar"); err != nil { - b.Fatal(err) - } - } - }) - - b.Run("redigo", func(b *B) { - red := newRedigo() - b.ResetTimer() - for i := 0; i < b.N; i++ { - if _, err := red.Do("SET", "foo", "bar"); err != nil { - b.Fatal(err) - } - if _, err := redigo.String(red.Do("GET", "foo")); err != nil { - b.Fatal(err) - } - } - }) - - b.Run("redispipe", func(b *B) { - sync := newRedisPipe(150 * time.Microsecond) - defer sync.S.Close() - b.ResetTimer() - for i := 0; i < b.N; i++ { - if res := sync.Do("SET", "foo", "bar"); redispipe.AsError(res) != nil { - b.Fatal(res) - } else if res := sync.Do("GET", "foo"); redispipe.AsError(res) != nil { - b.Fatal(res) - } - } - }) - - b.Run("redispipe_pause0", func(b *B) { - sync := newRedisPipe(-1) - defer sync.S.Close() - b.ResetTimer() - for i := 0; i < b.N; i++ { - if res := sync.Do("SET", "foo", "bar"); redispipe.AsError(res) != nil { - b.Fatal(res) - } - if res := sync.Do("GET", "foo"); redispipe.AsError(res) != nil { - b.Fatal(res) - } - } - }) -} - -func BenchmarkSerialGetSetLargeArgs(b *B) { - key := strings.Repeat("foo", 24) - val := strings.Repeat("bar", 4096) - - b.Run("radix", func(b *B) { - rad, err := radix.Dial("tcp", "127.0.0.1:6379") - if err != nil { - b.Fatal(err) - } - defer rad.Close() - // avoid overhead of converting from radix.Conn to radix.Client on each loop iteration - client := radix.Client(rad) - b.ResetTimer() - for i := 0; i < b.N; i++ { - if err := radixGetSet(client, key, val); err != nil { - b.Fatal(err) - } - } - }) - - b.Run("redigo", func(b *B) { - red := newRedigo() - b.ResetTimer() - for i := 0; i < b.N; i++ { - if _, err := red.Do("SET", key, val); err != nil { - b.Fatal(err) - } - if _, err := redigo.String(red.Do("GET", key)); err != nil { - b.Fatal(err) - } - } - }) - - b.Run("redispipe", func(b *B) { - sync := newRedisPipe(150 * time.Microsecond) - defer sync.S.Close() - b.ResetTimer() - for i := 0; i < b.N; i++ { - if res := sync.Do("SET", key, val); redispipe.AsError(res) != nil { - b.Fatal(res) - } - if res := sync.Do("GET", key); redispipe.AsError(res) != nil { - b.Fatal(res) - } - } - }) - - b.Run("redispipe_pause0", func(b *B) { - sync := newRedisPipe(-1) - defer sync.S.Close() - b.ResetTimer() - for i := 0; i < b.N; i++ { - if res := sync.Do("SET", key, val); redispipe.AsError(res) != nil { - b.Fatal(res) - } - if res := sync.Do("GET", key); redispipe.AsError(res) != nil { - b.Fatal(res) - } - } - }) -} - -func BenchmarkParallelGetSet(b *B) { - // parallel defines a multiplicand used for determining the number of goroutines - // for running benchmarks. this value will be multiplied by GOMAXPROCS inside RunParallel. - // since these benchmarks are mostly I/O bound and applications tend to have more - // active goroutines accessing Redis than cores, especially with higher core numbers, - // we set this to GOMAXPROCS so that we get GOMAXPROCS^2 connections. - parallel := runtime.GOMAXPROCS(0) - - // multiply parallel with GOMAXPROCS to get the actual number of goroutines and thus - // connections needed for the benchmarks. - poolSize := parallel * runtime.GOMAXPROCS(0) - - do := func(b *B, fn func() error) { - b.ResetTimer() - b.SetParallelism(parallel) - b.RunParallel(func(pb *PB) { - for pb.Next() { - if err := fn(); err != nil { - b.Fatal(err) - } - } - }) - } - - b.Run("radix", func(b *B) { - mkRadixBench := func(opts ...radix.PoolOpt) func(b *B) { - return func(b *B) { - pool, err := radix.NewPool("tcp", "127.0.0.1:6379", poolSize, opts...) - if err != nil { - b.Fatal(err) - } - defer pool.Close() - - // wait for the pool to fill up - for { - time.Sleep(50 * time.Millisecond) - if pool.NumAvailConns() >= poolSize { - break - } - } - - // avoid overhead of boxing the pool on each loop iteration - client := radix.Client(pool) - b.ResetTimer() - do(b, func() error { - return radixGetSet(client, "foo", "bar") - }) - } - } - - b.Run("no pipeline", mkRadixBench(radix.PoolPipelineWindow(0, 0))) - b.Run("one pipeline", mkRadixBench(radix.PoolPipelineConcurrency(1))) - b.Run("default", mkRadixBench()) - }) - - b.Run("redigo", func(b *B) { - red := &redigo.Pool{MaxIdle: poolSize, Dial: func() (redigo.Conn, error) { - return newRedigo(), nil - }} - defer red.Close() - - { // make sure the pool is full - var conns []redigo.Conn - for red.MaxIdle > red.ActiveCount() { - conns = append(conns, red.Get()) - } - for _, conn := range conns { - _ = conn.Close() - } - } - - do(b, func() error { - conn := red.Get() - if _, err := conn.Do("SET", "foo", "bar"); err != nil { - conn.Close() - return err - } - if out, err := redigo.String(conn.Do("GET", "foo")); err != nil { - conn.Close() - return err - } else if out != "bar" { - conn.Close() - return errors.New("got wrong value") - } - return conn.Close() - }) - }) - - b.Run("redispipe", func(b *B) { - sync := newRedisPipe(150 * time.Microsecond) - defer sync.S.Close() - do(b, func() error { - if res := sync.Do("SET", "foo", "bar"); redispipe.AsError(res) != nil { - return redispipe.AsError(res) - } else if res := sync.Do("GET", "foo"); redispipe.AsError(res) != nil { - return redispipe.AsError(res) - } - return nil - }) - }) -} diff --git a/bench/go.mod b/bench/go.mod deleted file mode 100644 index e768b85c..00000000 --- a/bench/go.mod +++ /dev/null @@ -1,12 +0,0 @@ -module github.com/mediocregopher/radix/bench - -require ( - github.com/garyburd/redigo v1.6.0 // indirect - github.com/gomodule/redigo v2.0.0+incompatible - github.com/joomcode/errorx v0.8.0 // indirect - github.com/joomcode/redispipe v0.9.0 - github.com/mediocregopher/radix.v2 v0.0.0-20181115013041-b67df6e626f9 // indirect - github.com/mediocregopher/radix/v3 v3.2.0 -) - -replace github.com/mediocregopher/radix/v3 => ../. diff --git a/bench/go.sum b/bench/go.sum deleted file mode 100644 index 4db9cfd4..00000000 --- a/bench/go.sum +++ /dev/null @@ -1,18 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/garyburd/redigo v1.6.0 h1:0VruCpn7yAIIu7pWVClQC8wxCJEcG3nyzpMSHKi1PQc= -github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= -github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0= -github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= -github.com/joomcode/errorx v0.8.0 h1:GhAqPtcYuo1O7TOIbtzEIDzPGQ3SrKJ3tdjXNmUtDNo= -github.com/joomcode/errorx v0.8.0/go.mod h1:kgco15ekB6cs+4Xjzo7SPeXzx38PbJzBwbnu9qfVNHQ= -github.com/joomcode/redispipe v0.9.0 h1:NukwwIvxhg6r2lVxa1RJhEZXYPZZF/OX9WZJk+2cK1Q= -github.com/joomcode/redispipe v0.9.0/go.mod h1:4S/gpBCZ62pB/3+XLNWDH7jQnB0vxmpddAMBva2adpM= -github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed h1:3dQJqqDouawQgl3gBE1PNHKFkJYGEuFb1DbSlaxdosE= -github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go.mod h1:dSsfyI2zABAdhcbvkXqgxOxrCsbYeHCPgrZkku60dSg= -github.com/mediocregopher/radix.v2 v0.0.0-20181115013041-b67df6e626f9 h1:ViNuGS149jgnttqhc6XQNPwdupEMBXqCx9wtlW7P3sA= -github.com/mediocregopher/radix.v2 v0.0.0-20181115013041-b67df6e626f9/go.mod h1:fLRUbhbSd5Px2yKUaGYYPltlyxi1guJz1vCmo1RQL50= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/cluster.go b/cluster.go index dfe799e5..0e22b6c5 100644 --- a/cluster.go +++ b/cluster.go @@ -7,8 +7,8 @@ import ( "sync" "time" - "github.com/mediocregopher/radix/v3/resp" - "github.com/mediocregopher/radix/v3/resp/resp2" + "github.com/groupme/radix/resp" + "github.com/groupme/radix/resp/resp2" ) // dedupe is used to deduplicate a function invocation, so if multiple diff --git a/cluster_stub_test.go b/cluster_stub_test.go index cfbb4fbd..fcbe6ce1 100644 --- a/cluster_stub_test.go +++ b/cluster_stub_test.go @@ -9,7 +9,7 @@ import ( "sync" . "testing" - "github.com/mediocregopher/radix/v3/resp/resp2" + "github.com/groupme/radix/resp/resp2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/cluster_topo.go b/cluster_topo.go index 996489a6..c1c48839 100644 --- a/cluster_topo.go +++ b/cluster_topo.go @@ -7,8 +7,8 @@ import ( "net" "sort" - "github.com/mediocregopher/radix/v3/resp" - "github.com/mediocregopher/radix/v3/resp/resp2" + "github.com/groupme/radix/resp" + "github.com/groupme/radix/resp/resp2" ) // ClusterNode describes a single node in the cluster at a moment in time. diff --git a/cluster_topo_test.go b/cluster_topo_test.go index 80a5b1d3..4a5318f0 100644 --- a/cluster_topo_test.go +++ b/cluster_topo_test.go @@ -5,8 +5,8 @@ import ( "bytes" . "testing" - "github.com/mediocregopher/radix/v3/resp" - "github.com/mediocregopher/radix/v3/resp/resp2" + "github.com/groupme/radix/resp" + "github.com/groupme/radix/resp/resp2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/gm-patch.sh b/gm-patch.sh new file mode 100755 index 00000000..6e8ea583 --- /dev/null +++ b/gm-patch.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +sed -i 's/mediocregopher\/radix\/v3/groupme\/radix/g' *.go +sed -i 's/mediocregopher\/radix\/v3/groupme\/radix/g' ./resp/resp2/*.go +rm ./go.mod +rm ./go.sum +rm -rf ./bench + +# Because those depends on stretchr libraries which fails +rm ./scanner_test.go +rm ./stream_test.go + +echo "# Radix + +forked and patched from github.com/mediocregopher/radix to overcome issues with golang modules + +" > ./README.md \ No newline at end of file diff --git a/go.mod b/go.mod deleted file mode 100644 index 89615da0..00000000 --- a/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module github.com/mediocregopher/radix/v3 - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v1.2.2 -) diff --git a/go.sum b/go.sum deleted file mode 100644 index 577164bd..00000000 --- a/go.sum +++ /dev/null @@ -1,8 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed h1:3dQJqqDouawQgl3gBE1PNHKFkJYGEuFb1DbSlaxdosE= -github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go.mod h1:dSsfyI2zABAdhcbvkXqgxOxrCsbYeHCPgrZkku60dSg= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/pool.go b/pool.go index 33f41d31..aef78e0a 100644 --- a/pool.go +++ b/pool.go @@ -7,7 +7,7 @@ import ( "sync" "time" - "github.com/mediocregopher/radix/v3/resp" + "github.com/groupme/radix/resp" ) // ErrPoolEmpty is used by Pools created using the PoolOnEmptyErrAfter option diff --git a/pubsub.go b/pubsub.go index 6d2a931d..4fe7dada 100644 --- a/pubsub.go +++ b/pubsub.go @@ -10,8 +10,8 @@ import ( "sync" "time" - "github.com/mediocregopher/radix/v3/resp" - "github.com/mediocregopher/radix/v3/resp/resp2" + "github.com/groupme/radix/resp" + "github.com/groupme/radix/resp/resp2" ) // PubSubMessage describes a message being published to a subscribed channel diff --git a/pubsub_stub.go b/pubsub_stub.go index 5140a37c..16c44783 100644 --- a/pubsub_stub.go +++ b/pubsub_stub.go @@ -7,8 +7,8 @@ import ( "strings" "sync" - "github.com/mediocregopher/radix/v3/resp" - "github.com/mediocregopher/radix/v3/resp/resp2" + "github.com/groupme/radix/resp" + "github.com/groupme/radix/resp/resp2" ) var errPubSubMode = resp2.Error{ diff --git a/pubsub_stub_test.go b/pubsub_stub_test.go index f064350b..d635e889 100644 --- a/pubsub_stub_test.go +++ b/pubsub_stub_test.go @@ -5,7 +5,7 @@ import ( . "testing" "time" - "github.com/mediocregopher/radix/v3/resp/resp2" + "github.com/groupme/radix/resp/resp2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/radix.go b/radix.go index 928b3184..596bb979 100644 --- a/radix.go +++ b/radix.go @@ -138,7 +138,7 @@ import ( "strings" "time" - "github.com/mediocregopher/radix/v3/resp" + "github.com/groupme/radix/resp" ) var errClientClosed = errors.New("client is closed") diff --git a/resp/resp2/resp.go b/resp/resp2/resp.go index 03e3af7d..3c9ffb37 100644 --- a/resp/resp2/resp.go +++ b/resp/resp2/resp.go @@ -17,9 +17,9 @@ import ( "strconv" "sync" - "github.com/mediocregopher/radix/v3/internal/bytesutil" + "github.com/groupme/radix/internal/bytesutil" - "github.com/mediocregopher/radix/v3/resp" + "github.com/groupme/radix/resp" ) var delim = []byte{'\r', '\n'} diff --git a/resp/resp2/resp_test.go b/resp/resp2/resp_test.go index 4fa248fe..f7b89001 100644 --- a/resp/resp2/resp_test.go +++ b/resp/resp2/resp_test.go @@ -7,7 +7,7 @@ import ( "reflect" . "testing" - "github.com/mediocregopher/radix/v3/resp" + "github.com/groupme/radix/resp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/scanner.go b/scanner.go index 8e011f4d..347bd049 100644 --- a/scanner.go +++ b/scanner.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "github.com/mediocregopher/radix/v3/resp/resp2" + "github.com/groupme/radix/resp/resp2" ) // Scanner is used to iterate through the results of a SCAN call (or HSCAN, diff --git a/scanner_test.go b/scanner_test.go deleted file mode 100644 index 875afe08..00000000 --- a/scanner_test.go +++ /dev/null @@ -1,125 +0,0 @@ -package radix - -import ( - "log" - "strconv" - . "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestScanner(t *T) { - c := dial() - - // Make a random dataset - prefix := randStr() - fullMap := map[string]bool{} - for i := 0; i < 100; i++ { - key := prefix + ":" + strconv.Itoa(i) - fullMap[key] = true - require.Nil(t, c.Do(Cmd(nil, "SET", key, "1"))) - } - - // make sure we get all results when scanning with an existing prefix - sc := NewScanner(c, ScanOpts{Command: "SCAN", Pattern: prefix + ":*"}) - var key string - for sc.Next(&key) { - delete(fullMap, key) - } - require.Nil(t, sc.Close()) - assert.Empty(t, fullMap) - - // make sure we don't get any results when scanning with a non-existing - // prefix - sc = NewScanner(c, ScanOpts{Command: "SCAN", Pattern: prefix + "DNE:*"}) - assert.False(t, sc.Next(nil)) - require.Nil(t, sc.Close()) -} - -// Similar to TestScanner, but scans over a set instead of the whole key space -func TestScannerSet(t *T) { - c := dial() - - key := randStr() - fullMap := map[string]bool{} - for i := 0; i < 100; i++ { - elem := strconv.Itoa(i) - fullMap[elem] = true - require.Nil(t, c.Do(Cmd(nil, "SADD", key, elem))) - } - - // make sure we get all results when scanning an existing set - sc := NewScanner(c, ScanOpts{Command: "SSCAN", Key: key}) - var val string - for sc.Next(&val) { - delete(fullMap, val) - } - require.Nil(t, sc.Close()) - assert.Empty(t, fullMap) - - // make sure we don't get any results when scanning a non-existent set - sc = NewScanner(c, ScanOpts{Command: "SSCAN", Key: key + "DNE"}) - assert.False(t, sc.Next(nil)) - require.Nil(t, sc.Close()) -} - -func BenchmarkScanner(b *B) { - c := dial() - - const total = 10 * 1000 - - // Make a random dataset - prefix := randStr() - for i := 0; i < total; i++ { - key := prefix + ":" + strconv.Itoa(i) - require.Nil(b, c.Do(Cmd(nil, "SET", key, "1"))) - } - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - // make sure we get all results when scanning with an existing prefix - sc := NewScanner(c, ScanOpts{Command: "SCAN", Pattern: prefix + ":*"}) - var key string - var got int - for sc.Next(&key) { - got++ - } - if got != total { - require.Failf(b, "mismatched between inserted and scanned keys", "expected %d keys, got %d", total, got) - } - } -} - -func ExampleNewScanner_scan() { - client, err := DefaultClientFunc("tcp", "126.0.0.1:6379") - if err != nil { - log.Fatal(err) - } - - s := NewScanner(client, ScanAllKeys) - var key string - for s.Next(&key) { - log.Printf("key: %q", key) - } - if err := s.Close(); err != nil { - log.Fatal(err) - } -} - -func ExampleNewScanner_hscan() { - client, err := DefaultClientFunc("tcp", "126.0.0.1:6379") - if err != nil { - log.Fatal(err) - } - - s := NewScanner(client, ScanOpts{Command: "HSCAN", Key: "somekey"}) - var key string - for s.Next(&key) { - log.Printf("key: %q", key) - } - if err := s.Close(); err != nil { - log.Fatal(err) - } -} diff --git a/stream.go b/stream.go index 193dacbe..6c57501e 100644 --- a/stream.go +++ b/stream.go @@ -10,9 +10,9 @@ import ( "strconv" "time" - "github.com/mediocregopher/radix/v3/internal/bytesutil" - "github.com/mediocregopher/radix/v3/resp" - "github.com/mediocregopher/radix/v3/resp/resp2" + "github.com/groupme/radix/internal/bytesutil" + "github.com/groupme/radix/resp" + "github.com/groupme/radix/resp/resp2" ) // StreamEntryID represents an ID used in a Redis stream with the format