Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade go-redis from v8 to v9 #793

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@ require (
github.com/aws/aws-sdk-go v1.37.16
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/go-redis/redis/v8 v8.6.0
github.com/go-redsync/redsync/v4 v4.0.4
github.com/go-redsync/redsync/v4 v4.8.1
github.com/golang/snappy v0.0.2 // indirect
github.com/gomodule/redigo v2.0.0+incompatible
github.com/gomodule/redigo v1.8.10-0.20230511231101-78e255f9bd2a
github.com/google/uuid v1.2.0
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/kelseyhightower/envconfig v1.4.0
github.com/klauspost/compress v1.11.7 // indirect
github.com/opentracing/opentracing-go v1.2.0
github.com/pkg/errors v0.9.1
github.com/redis/go-redis/v9 v9.0.5
github.com/robfig/cron/v3 v3.0.1
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/streadway/amqp v1.0.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.1
github.com/urfave/cli v1.22.5
github.com/xdg/stringprep v1.0.0 // indirect
go.mongodb.org/mongo-driver v1.4.6
Expand Down
101 changes: 50 additions & 51 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions v1/backends/redis/goredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"sync"
"time"

"github.com/go-redis/redis/v8"
"github.com/go-redsync/redsync/v4"
redsyncgoredis "github.com/go-redsync/redsync/v4/redis/goredis/v8"
redsyncgoredis "github.com/go-redsync/redsync/v4/redis/goredis/v9"
"github.com/redis/go-redis/v9"

"github.com/RichardKnop/machinery/v1/backends/iface"
"github.com/RichardKnop/machinery/v1/common"
Expand Down
4 changes: 2 additions & 2 deletions v1/brokers/redis/goredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"sync"
"time"

"github.com/go-redis/redis/v8"
"github.com/go-redsync/redsync/v4"
"github.com/redis/go-redis/v9"

"github.com/RichardKnop/machinery/v1/brokers/errs"
"github.com/RichardKnop/machinery/v1/brokers/iface"
Expand Down Expand Up @@ -195,7 +195,7 @@ func (b *BrokerGR) Publish(ctx context.Context, signature *tasks.Signature) erro

if signature.ETA.After(now) {
score := signature.ETA.UnixNano()
err = b.rclient.ZAdd(context.Background(), b.redisDelayedTasksKey, &redis.Z{Score: float64(score), Member: msg}).Err()
err = b.rclient.ZAdd(context.Background(), b.redisDelayedTasksKey, redis.Z{Score: float64(score), Member: msg}).Err()
return err
}
}
Expand Down
6 changes: 4 additions & 2 deletions v1/locks/redis/redis.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package redis

import (
"context"
"errors"
"strconv"
"strings"
"time"

"github.com/RichardKnop/machinery/v1/config"
"github.com/go-redis/redis/v8"
"github.com/redis/go-redis/v9"
)

var (
Expand Down Expand Up @@ -64,7 +65,8 @@ func (r Lock) LockWithRetries(key string, unixTsToExpireNs int64) error {
func (r Lock) Lock(key string, unixTsToExpireNs int64) error {
now := time.Now().UnixNano()
expiration := time.Duration(unixTsToExpireNs + 1 - now)
ctx := r.rclient.Context()
// ctx := r.rclient.Context()
ctx := context.Background()

success, err := r.rclient.SetNX(ctx, key, unixTsToExpireNs, expiration).Result()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions v2/backends/redis/goredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"sync"
"time"

"github.com/go-redis/redis/v8"
"github.com/go-redsync/redsync/v4"
redsyncgoredis "github.com/go-redsync/redsync/v4/redis/goredis/v8"
redsyncgoredis "github.com/go-redsync/redsync/v4/redis/goredis/v9"
"github.com/redis/go-redis/v9"

"github.com/RichardKnop/machinery/v2/backends/iface"
"github.com/RichardKnop/machinery/v2/common"
Expand Down
4 changes: 2 additions & 2 deletions v2/brokers/redis/goredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"sync"
"time"

"github.com/go-redis/redis/v8"
"github.com/go-redsync/redsync/v4"
"github.com/redis/go-redis/v9"

"github.com/RichardKnop/machinery/v2/brokers/errs"
"github.com/RichardKnop/machinery/v2/brokers/iface"
Expand Down Expand Up @@ -195,7 +195,7 @@ func (b *BrokerGR) Publish(ctx context.Context, signature *tasks.Signature) erro

if signature.ETA.After(now) {
score := signature.ETA.UnixNano()
err = b.rclient.ZAdd(context.Background(), b.redisDelayedTasksKey, &redis.Z{Score: float64(score), Member: msg}).Err()
err = b.rclient.ZAdd(context.Background(), b.redisDelayedTasksKey, redis.Z{Score: float64(score), Member: msg}).Err()
return err
}
}
Expand Down
6 changes: 3 additions & 3 deletions v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ require (
github.com/RichardKnop/logging v0.0.0-20190827224416-1a693bdd4fae
github.com/aws/aws-sdk-go v1.37.16
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
github.com/go-redis/redis/v8 v8.6.0
github.com/go-redsync/redsync/v4 v4.0.4
github.com/go-redsync/redsync/v4 v4.8.1
github.com/gomodule/redigo v2.0.0+incompatible
github.com/google/uuid v1.2.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/opentracing/opentracing-go v1.2.0
github.com/pkg/errors v0.9.1
github.com/redis/go-redis/v9 v9.0.5
github.com/robfig/cron/v3 v3.0.1
github.com/streadway/amqp v1.0.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.1
github.com/urfave/cli v1.22.5
go.mongodb.org/mongo-driver v1.4.6
gopkg.in/yaml.v2 v2.4.0
Expand Down
Loading