Skip to content

Commit

Permalink
Bump to redis v9 (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-dunn-sublime authored Mar 8, 2024
1 parent f9ce7c7 commit c7bc668
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 62 deletions.
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ 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.12.1
github.com/gomodule/redigo v2.0.0+incompatible
github.com/google/uuid v1.2.0
github.com/hashicorp/errwrap v1.1.0 // indirect
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.5.1
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.3
github.com/urfave/cli v1.22.5
go.opencensus.io v0.22.6 // indirect
golang.org/x/oauth2 v0.0.0-20210201163806-010130855d6c // indirect
Expand Down
228 changes: 186 additions & 42 deletions go.sum

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions v1/backends/redis/goredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ 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"

"github.com/RichardKnop/machinery/v1/backends/iface"
"github.com/RichardKnop/machinery/v1/common"
"github.com/RichardKnop/machinery/v1/config"
"github.com/RichardKnop/machinery/v1/log"
"github.com/RichardKnop/machinery/v1/tasks"
"github.com/go-redsync/redsync/v4"
redsyncgoredis "github.com/go-redsync/redsync/v4/redis/goredis/v9"
"github.com/redis/go-redis/v9"
)

// BackendGR represents a Redis result backend
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 @@ -10,8 +10,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 @@ -186,7 +186,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
7 changes: 3 additions & 4 deletions v2/backends/redis/goredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ 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"

"github.com/RichardKnop/machinery/v2/backends/iface"
"github.com/RichardKnop/machinery/v2/common"
"github.com/RichardKnop/machinery/v2/config"
"github.com/RichardKnop/machinery/v2/log"
"github.com/RichardKnop/machinery/v2/tasks"
"github.com/go-redis/redis"
"github.com/go-redsync/redsync/v4"
redsyncgoredis "github.com/go-redsync/redsync/v4/redis/goredis/v9"
)

// BackendGR represents a Redis result backend
Expand Down
5 changes: 2 additions & 3 deletions v2/brokers/redis/goredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import (
"sync"
"time"

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

"github.com/RichardKnop/machinery/v2/brokers/errs"
"github.com/RichardKnop/machinery/v2/brokers/iface"
"github.com/RichardKnop/machinery/v2/common"
"github.com/RichardKnop/machinery/v2/config"
"github.com/RichardKnop/machinery/v2/log"
"github.com/RichardKnop/machinery/v2/tasks"
"github.com/go-redis/redis"
"github.com/go-redsync/redsync/v4"
)

// BrokerGR represents a Redis broker
Expand Down
2 changes: 1 addition & 1 deletion v2/locks/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

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

var (
Expand Down

0 comments on commit c7bc668

Please sign in to comment.