Skip to content

Commit 0694a69

Browse files
committed
Bump github.com/go-redis/redis from v6 to v8
1 parent e20e094 commit 0694a69

File tree

651 files changed

+150886
-144127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

651 files changed

+150886
-144127
lines changed

buckets/redis/bucket.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strconv"
1111
"time"
1212

13-
"github.com/go-redis/redis"
13+
"github.com/go-redis/redis/v8"
1414

1515
"github.com/opentracing/opentracing-go"
1616
"github.com/pkg/errors"
@@ -80,7 +80,7 @@ func (a *abstractBucket) Take(ctx context.Context, requested int64, maxWaitTime
8080
func (a *abstractBucket) takeFromRedis(ctx context.Context, client redis.UniversalClient, args []interface{}) *redis.Cmd {
8181
span, ctx := opentracing.StartSpanFromContext(ctx, "script.Run")
8282
defer span.Finish()
83-
return a.factory.script.Run(client, a.keys, args...)
83+
return a.factory.script.Run(ctx, client, a.keys, args...)
8484
}
8585

8686
var _ quotaservice.Bucket = (*staticBucket)(nil)

buckets/redis/bucket_factory.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
package redis
77

88
import (
9+
"context"
910
"fmt"
1011
"strconv"
1112
"sync"
1213
"time"
1314

14-
"github.com/go-redis/redis"
15+
"github.com/go-redis/redis/v8"
1516

1617
"github.com/pkg/errors"
1718
"github.com/square/quotaservice"
@@ -190,7 +191,7 @@ func (bf *bucketFactory) connectToRedisLocked() {
190191
logging.Fatal("Cannot connect to Redis because no connection options have been provided.")
191192
}
192193

193-
_, err := bf.client.Touch("areYouAlive?").Result()
194+
_, err := bf.client.Touch(context.TODO(), "areYouAlive?").Result()
194195
if err != nil {
195196
logging.Printf("Cannot connect to Redis. TOUCH returned %v", err)
196197
} else {
@@ -238,7 +239,7 @@ func (bf *bucketFactory) establishNewConnectionToRedis(oldClient redis.Universal
238239
bf.reconnectToRedis(client)
239240

240241
client = bf.Client().(redis.UniversalClient)
241-
_, err := client.Ping().Result()
242+
_, err := client.Ping(context.TODO()).Result()
242243
if err == nil {
243244
disconnected = false
244245
break

buckets/redis/bucket_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import (
99
"testing"
1010
"time"
1111

12-
"github.com/go-redis/redis"
12+
"github.com/go-redis/redis/v8"
1313

1414
"github.com/square/quotaservice/buckets"
1515
"github.com/square/quotaservice/config"
16-
"github.com/square/quotaservice/protos/config"
16+
quotaservice_configs "github.com/square/quotaservice/protos/config"
1717
)
1818

1919
const (
@@ -48,7 +48,7 @@ func setUp() {
4848
func TestScriptLoaded(t *testing.T) {
4949
bucket.Take(context.Background(), 1, 50*time.Millisecond)
5050

51-
exists := bucket.factory.script.Exists(bucket.factory.client)
51+
exists := bucket.factory.script.Exists(context.TODO(), bucket.factory.client)
5252
if err := exists.Err(); err != nil {
5353
t.Fatal("Error checking if script was loaded into Redis: ", err)
5454
} else if !exists.Val()[0] {

go.mod

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,27 @@ require (
1010
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 // indirect
1111
github.com/alecthomas/template v0.0.0-20150530000104-b867cc6ab45c // indirect
1212
github.com/alecthomas/units v0.0.0-20150109002421-6b4e7dc5e314 // indirect
13-
github.com/go-redis/redis v6.15.2+incompatible
13+
github.com/go-redis/redis/v8 v8.11.5
1414
github.com/go-sql-driver/mysql v1.4.1
1515
github.com/go-zookeeper/zk v1.0.2
16-
github.com/golang/protobuf v1.2.0
16+
github.com/golang/protobuf v1.5.2
1717
github.com/googleapis/gax-go v0.0.0-20170305230405-8c5154c0fe5b // indirect
1818
github.com/kr/pretty v0.1.0 // indirect
1919
github.com/lib/pq v1.0.0 // indirect
2020
github.com/mattn/go-isatty v0.0.4 // indirect
2121
github.com/mattn/go-sqlite3 v1.9.0 // indirect
22-
github.com/onsi/ginkgo v1.7.0 // indirect
23-
github.com/onsi/gomega v1.4.3 // indirect
2422
github.com/opentracing/opentracing-go v1.0.2
2523
github.com/ory/dockertest/v3 v3.6.0
2624
github.com/pkg/errors v0.8.1
2725
github.com/sergi/go-diff v1.0.0 // indirect
28-
github.com/stretchr/testify v1.4.0
29-
golang.org/x/net v0.0.0-20191003171128-d98b1b443823
26+
github.com/stretchr/testify v1.5.1
27+
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781
3028
golang.org/x/oauth2 v0.0.0-20170302202304-efb10a30610e // indirect
3129
google.golang.org/api v0.0.0-20170308235209-f093df3d954a
3230
google.golang.org/appengine v1.0.0 // indirect
3331
google.golang.org/genproto v0.0.0-20170303204730-1e95789587db // indirect
3432
google.golang.org/grpc v0.0.0-20170307005400-4eaacfed9779
3533
gopkg.in/alecthomas/kingpin.v2 v2.2.3
3634
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
37-
gopkg.in/yaml.v2 v2.2.7
35+
gopkg.in/yaml.v2 v2.4.0
3836
)

go.sum

Lines changed: 90 additions & 17 deletions
Large diffs are not rendered by default.

stats/redis.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
package stats
55

66
import (
7+
"context"
78
"fmt"
89
"sync"
910
"time"
1011

11-
"github.com/go-redis/redis"
12+
"github.com/go-redis/redis/v8"
1213

1314
"github.com/square/quotaservice/events"
1415
"github.com/square/quotaservice/logging"
@@ -28,7 +29,7 @@ type redisListener struct {
2829
// by a standalone Redis instance.
2930
func NewRedisStatsListener(redisOpts *redis.Options, statsBatchSize int, statsBatchDeadline time.Duration) Listener {
3031
client := redis.NewClient(redisOpts)
31-
_, err := client.Ping().Result()
32+
_, err := client.Ping(context.TODO()).Result()
3233

3334
if err != nil {
3435
logging.Fatalf("RedisStatsListener: cannot connect to Redis, %v", err)
@@ -53,7 +54,7 @@ func NewRedisStatsListener(redisOpts *redis.Options, statsBatchSize int, statsBa
5354
// by a Redis cluster.
5455
func NewRedisClusterStatsListener(redisClusterOpts *redis.ClusterOptions, statsBatchSize int, statsBatchDeadline time.Duration) Listener {
5556
client := redis.NewClusterClient(redisClusterOpts)
56-
_, err := client.Ping().Result()
57+
_, err := client.Ping(context.TODO()).Result()
5758

5859
if err != nil {
5960
logging.Fatalf("RedisStatsListener: cannot connect to Redis, %v", err)
@@ -75,7 +76,7 @@ func NewRedisClusterStatsListener(redisClusterOpts *redis.ClusterOptions, statsB
7576
}
7677

7778
func (l *redisListener) redisTopList(key string) []*BucketScore {
78-
results, err := l.client.ZRevRangeWithScores(key, 0, 10).Result()
79+
results, err := l.client.ZRevRangeWithScores(context.TODO(), key, 0, 10).Result()
7980

8081
if err != nil && err.Error() != "redis: nil" {
8182
logging.Printf("RedisStatsListener.TopList error (%s) %v", key, err)
@@ -115,15 +116,15 @@ func (l *redisListener) TopMisses(namespace string) []*BucketScore {
115116
func (l *redisListener) Get(namespace, bucket string) *BucketScores {
116117
scores := &BucketScores{0, 0}
117118

118-
value, err := l.client.ZScore(statsNamespace("misses", namespace), bucket).Result()
119+
value, err := l.client.ZScore(context.TODO(), statsNamespace("misses", namespace), bucket).Result()
119120

120121
if err != nil && err.Error() != "redis: nil" {
121122
logging.Printf("RedisStatsListener.Get error (%s, %s) %v", namespace, bucket, err)
122123
} else {
123124
scores.Misses = int64(value)
124125
}
125126

126-
value, err = l.client.ZScore(statsNamespace("hits", namespace), bucket).Result()
127+
value, err = l.client.ZScore(context.TODO(), statsNamespace("hits", namespace), bucket).Result()
127128

128129
if err != nil && err.Error() != "redis: nil" {
129130
logging.Printf("RedisStatsListener.Get error (%s, %s) %v", namespace, bucket, err)
@@ -168,8 +169,8 @@ func (l *redisListener) HandleEvent(event events.Event) {
168169
func (l *redisListener) queueStatsUpdate(namespace string, numTokens int64, bucket string) {
169170
l.statsUpdatesLock.Lock()
170171

171-
l.pipe.ZIncrBy(namespace, float64(numTokens), bucket)
172-
l.pipe.ExpireAt(namespace, nearestHour())
172+
l.pipe.ZIncrBy(context.TODO(), namespace, float64(numTokens), bucket)
173+
l.pipe.ExpireAt(context.TODO(), namespace, nearestHour())
173174

174175
l.queuedUpdates++
175176

@@ -231,7 +232,7 @@ func (l *redisListener) batcher() {
231232

232233
// submitBatch executes the provided pipeline and checks for errors.
233234
func (l *redisListener) submitBatch(pipe redis.Pipeliner) {
234-
cmds, err := pipe.Exec()
235+
cmds, err := pipe.Exec(context.TODO())
235236
if err != nil {
236237
logging.Printf("RedisStatsListener.HandleEvent pipeline error %v", err)
237238
}

stats/redis_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
package stats
55

66
import (
7+
"context"
78
"math/rand"
89
"reflect"
910
"testing"
1011
"time"
1112

12-
"github.com/go-redis/redis"
13+
"github.com/go-redis/redis/v8"
1314

1415
"github.com/square/quotaservice/events"
1516
)
@@ -43,7 +44,7 @@ func setUp() Listener {
4344
}
4445

4546
func teardown(listener Listener) {
46-
listener.(*redisListener).client.FlushDB()
47+
listener.(*redisListener).client.FlushDB(context.TODO())
4748
}
4849

4950
func TestRedisHandleNewHitBucket(t *testing.T) {

vendor/github.com/cespare/xxhash/v2/LICENSE.txt

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/cespare/xxhash/v2/README.md

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/cespare/xxhash/v2/go.mod

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)