2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-09-20 11:05:58 +08:00

Rename to RedisConfig

This commit is contained in:
Ken Hibino 2019-12-03 19:43:01 -08:00
parent 4afb3a2401
commit 57838600ef
6 changed files with 13 additions and 13 deletions

View File

@ -49,8 +49,8 @@ type taskMessage struct {
ErrorMsg string ErrorMsg string
} }
// RedisOpt specifies redis options. // RedisConfig specifies redis configurations.
type RedisOpt struct { type RedisConfig struct {
Addr string Addr string
Password string Password string

View File

@ -38,7 +38,7 @@ var sortTaskOpt = cmp.Transformer("SortMsg", func(in []*Task) []*Task {
// before returning an instance of rdb. // before returning an instance of rdb.
func setup(t *testing.T) *rdb { func setup(t *testing.T) *rdb {
t.Helper() t.Helper()
r := newRDB(&RedisOpt{ r := newRDB(&RedisConfig{
Addr: "localhost:6379", Addr: "localhost:6379",
DB: 15, // use database 15 to separate from other applications DB: 15, // use database 15 to separate from other applications
}) })

View File

@ -20,8 +20,8 @@ type Background struct {
} }
// NewBackground returns a new Background instance. // NewBackground returns a new Background instance.
func NewBackground(numWorkers int, opt *RedisOpt) *Background { func NewBackground(numWorkers int, config *RedisConfig) *Background {
rdb := newRDB(opt) rdb := newRDB(config)
poller := newPoller(rdb, 5*time.Second, []string{scheduled, retry}) poller := newPoller(rdb, 5*time.Second, []string{scheduled, retry})
processor := newProcessor(rdb, numWorkers, nil) processor := newProcessor(rdb, numWorkers, nil)
return &Background{ return &Background{

View File

@ -12,12 +12,12 @@ func TestBackground(t *testing.T) {
ignoreOpt := goleak.IgnoreTopFunction("github.com/go-redis/redis/v7/internal/pool.(*ConnPool).reaper") ignoreOpt := goleak.IgnoreTopFunction("github.com/go-redis/redis/v7/internal/pool.(*ConnPool).reaper")
defer goleak.VerifyNoLeaks(t, ignoreOpt) defer goleak.VerifyNoLeaks(t, ignoreOpt)
bg := NewBackground(10, &RedisOpt{ bg := NewBackground(10, &RedisConfig{
Addr: "localhost:6379", Addr: "localhost:6379",
DB: 15, DB: 15,
}) })
client := NewClient(&RedisOpt{ client := NewClient(&RedisConfig{
Addr: "localhost:6379", Addr: "localhost:6379",
DB: 15, DB: 15,
}) })

View File

@ -12,8 +12,8 @@ type Client struct {
} }
// NewClient creates and returns a new client. // NewClient creates and returns a new client.
func NewClient(opt *RedisOpt) *Client { func NewClient(config *RedisConfig) *Client {
return &Client{rdb: newRDB(opt)} return &Client{rdb: newRDB(config)}
} }
// Process enqueues the task to be performed at a given time. // Process enqueues the task to be performed at a given time.

8
rdb.go
View File

@ -28,11 +28,11 @@ type rdb struct {
client *redis.Client client *redis.Client
} }
func newRDB(opt *RedisOpt) *rdb { func newRDB(config *RedisConfig) *rdb {
client := redis.NewClient(&redis.Options{ client := redis.NewClient(&redis.Options{
Addr: opt.Addr, Addr: config.Addr,
Password: opt.Password, Password: config.Password,
DB: opt.DB, DB: config.DB,
}) })
return &rdb{client} return &rdb{client}
} }