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

Bump go redis v8 > v9 #37

Merged
merged 2 commits into from
Mar 25, 2024
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
2 changes: 1 addition & 1 deletion bokchoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"sync"

"github.com/go-redis/redis/v8"
"github.com/redis/go-redis/v9"
"github.com/thoas/bokchoy/logging"
"github.com/thoas/go-funk"

Expand Down
85 changes: 41 additions & 44 deletions broker_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/thoas/bokchoy/logging"

"github.com/go-redis/redis/v8"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
)

// RedisBroker is the redis broker.
Expand Down Expand Up @@ -76,54 +76,51 @@ func newRedisBroker(cfg RedisConfig, logger logging.Logger) *RedisBroker {
switch cfg.Type {
case redisTypeSentinel:
clt = redis.NewFailoverClient(&redis.FailoverOptions{
MasterName: cfg.Sentinel.MasterName,
SentinelAddrs: cfg.Sentinel.SentinelAddrs,
Password: cfg.Sentinel.Password,
MaxRetries: cfg.Sentinel.MaxRetries,
DialTimeout: cfg.Sentinel.DialTimeout,
ReadTimeout: cfg.Sentinel.ReadTimeout,
WriteTimeout: cfg.Sentinel.WriteTimeout,
PoolSize: cfg.Sentinel.PoolSize,
PoolTimeout: cfg.Sentinel.PoolTimeout,
IdleTimeout: cfg.Sentinel.IdleTimeout,
MinIdleConns: cfg.Sentinel.MinIdleConns,
MaxConnAge: cfg.Sentinel.MaxConnAge,
IdleCheckFrequency: cfg.Sentinel.IdleCheckFrequency,
MasterName: cfg.Sentinel.MasterName,
SentinelAddrs: cfg.Sentinel.SentinelAddrs,
Password: cfg.Sentinel.Password,
MaxRetries: cfg.Sentinel.MaxRetries,
DialTimeout: cfg.Sentinel.DialTimeout,
ReadTimeout: cfg.Sentinel.ReadTimeout,
WriteTimeout: cfg.Sentinel.WriteTimeout,
PoolSize: cfg.Sentinel.PoolSize,
PoolTimeout: cfg.Sentinel.PoolTimeout,
ConnMaxIdleTime: cfg.Sentinel.ConnMaxIdleTime,
ConnMaxLifetime: cfg.Sentinel.ConnMaxLifetime,
MinIdleConns: cfg.Sentinel.MinIdleConns,
})
case redisTypeCluster:
clt = redis.NewClusterClient(&redis.ClusterOptions{
Addrs: cfg.Cluster.Addrs,
Password: cfg.Cluster.Password,
MaxRetries: cfg.Cluster.MaxRetries,
DialTimeout: cfg.Cluster.DialTimeout,
ReadTimeout: cfg.Cluster.ReadTimeout,
WriteTimeout: cfg.Cluster.WriteTimeout,
PoolSize: cfg.Cluster.PoolSize,
PoolTimeout: cfg.Cluster.PoolTimeout,
IdleTimeout: cfg.Cluster.IdleTimeout,
MinIdleConns: cfg.Cluster.MinIdleConns,
MaxConnAge: cfg.Cluster.MaxConnAge,
IdleCheckFrequency: cfg.Cluster.IdleCheckFrequency,
ReadOnly: false,
RouteRandomly: false,
RouteByLatency: false,
Addrs: cfg.Cluster.Addrs,
Password: cfg.Cluster.Password,
MaxRetries: cfg.Cluster.MaxRetries,
DialTimeout: cfg.Cluster.DialTimeout,
ReadTimeout: cfg.Cluster.ReadTimeout,
WriteTimeout: cfg.Cluster.WriteTimeout,
PoolSize: cfg.Cluster.PoolSize,
PoolTimeout: cfg.Cluster.PoolTimeout,
ConnMaxIdleTime: cfg.Cluster.ConnMaxIdleTime,
ConnMaxLifetime: cfg.Cluster.ConnMaxLifetime,
MinIdleConns: cfg.Cluster.MinIdleConns,
ReadOnly: false,
RouteRandomly: false,
RouteByLatency: false,
})
default:
clt = redis.NewClient(&redis.Options{
Addr: cfg.Client.Addr,
Password: cfg.Client.Password,
DB: cfg.Client.DB,
MaxRetries: cfg.Client.MaxRetries,
DialTimeout: cfg.Client.DialTimeout,
ReadTimeout: cfg.Client.ReadTimeout,
WriteTimeout: cfg.Client.WriteTimeout,
PoolSize: cfg.Client.PoolSize,
PoolTimeout: cfg.Client.PoolTimeout,
IdleTimeout: cfg.Client.IdleTimeout,
MinIdleConns: cfg.Client.MinIdleConns,
MaxConnAge: cfg.Client.MaxConnAge,
IdleCheckFrequency: cfg.Client.IdleCheckFrequency,
TLSConfig: cfg.Client.TLSConfig,
Addr: cfg.Client.Addr,
Password: cfg.Client.Password,
DB: cfg.Client.DB,
MaxRetries: cfg.Client.MaxRetries,
DialTimeout: cfg.Client.DialTimeout,
ReadTimeout: cfg.Client.ReadTimeout,
WriteTimeout: cfg.Client.WriteTimeout,
PoolSize: cfg.Client.PoolSize,
PoolTimeout: cfg.Client.PoolTimeout,
ConnMaxIdleTime: cfg.Client.ConnMaxIdleTime,
ConnMaxLifetime: cfg.Client.ConnMaxLifetime,
MinIdleConns: cfg.Client.MinIdleConns,
TLSConfig: cfg.Client.TLSConfig,
})

}
Expand Down Expand Up @@ -480,7 +477,7 @@ func (p *RedisBroker) publish(ctx context.Context, client redis.Cmdable, queueNa
if eta.Before(time.Now().UTC()) {
err = client.LPush(ctx, p.prefixed(queueName), taskID).Err()
} else {
err = client.ZAdd(ctx, p.prefixed(fmt.Sprint(queueName, ":delay")), &redis.Z{
err = client.ZAdd(ctx, p.prefixed(fmt.Sprint(queueName, ":delay")), redis.Z{
Score: float64(eta.UTC().Unix()),
Member: taskID,
}).Err()
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package bokchoy

import "github.com/go-redis/redis/v8"
import "github.com/redis/go-redis/v9"

// RedisClusterConfig contains the redis cluster configuration.
type RedisClusterConfig redis.ClusterOptions
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-broker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"time"

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

"github.com/thoas/bokchoy"
"github.com/thoas/bokchoy/logging"
Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ require (
github.com/PuerkitoBio/goquery v1.5.1
github.com/davecgh/go-spew v1.1.1
github.com/getsentry/sentry-go v0.6.0
github.com/go-redis/redis/v8 v8.8.2
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.3
github.com/grpc-ecosystem/go-grpc-middleware v1.2.0
github.com/mitchellh/mapstructure v1.2.2
github.com/oklog/ulid v1.3.1
github.com/pkg/errors v0.9.1
github.com/redis/go-redis/v9 v9.4.0
github.com/stretchr/testify v1.8.1
github.com/thoas/go-funk v0.4.0
go.uber.org/zap v1.12.0
Expand All @@ -25,9 +25,6 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opentelemetry.io/otel v0.19.0 // indirect
go.opentelemetry.io/otel/metric v0.19.0 // indirect
go.opentelemetry.io/otel/trace v0.19.0 // indirect
go.uber.org/atomic v1.5.0 // indirect
go.uber.org/multierr v1.3.0 // indirect
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee // indirect
Expand Down
Loading
Loading