From 57838600ef2904c2758c8d2b1850f1beae0037e0 Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Tue, 3 Dec 2019 19:43:01 -0800 Subject: [PATCH] Rename to RedisConfig --- asynq.go | 4 ++-- asynq_test.go | 2 +- background.go | 4 ++-- background_test.go | 4 ++-- client.go | 4 ++-- rdb.go | 8 ++++---- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/asynq.go b/asynq.go index 517de6b..fd6d27a 100644 --- a/asynq.go +++ b/asynq.go @@ -49,8 +49,8 @@ type taskMessage struct { ErrorMsg string } -// RedisOpt specifies redis options. -type RedisOpt struct { +// RedisConfig specifies redis configurations. +type RedisConfig struct { Addr string Password string diff --git a/asynq_test.go b/asynq_test.go index 2ef8a20..d6e58cf 100644 --- a/asynq_test.go +++ b/asynq_test.go @@ -38,7 +38,7 @@ var sortTaskOpt = cmp.Transformer("SortMsg", func(in []*Task) []*Task { // before returning an instance of rdb. func setup(t *testing.T) *rdb { t.Helper() - r := newRDB(&RedisOpt{ + r := newRDB(&RedisConfig{ Addr: "localhost:6379", DB: 15, // use database 15 to separate from other applications }) diff --git a/background.go b/background.go index 3a0d5d8..d669425 100644 --- a/background.go +++ b/background.go @@ -20,8 +20,8 @@ type Background struct { } // NewBackground returns a new Background instance. -func NewBackground(numWorkers int, opt *RedisOpt) *Background { - rdb := newRDB(opt) +func NewBackground(numWorkers int, config *RedisConfig) *Background { + rdb := newRDB(config) poller := newPoller(rdb, 5*time.Second, []string{scheduled, retry}) processor := newProcessor(rdb, numWorkers, nil) return &Background{ diff --git a/background_test.go b/background_test.go index 1dec050..4a525b0 100644 --- a/background_test.go +++ b/background_test.go @@ -12,12 +12,12 @@ func TestBackground(t *testing.T) { ignoreOpt := goleak.IgnoreTopFunction("github.com/go-redis/redis/v7/internal/pool.(*ConnPool).reaper") defer goleak.VerifyNoLeaks(t, ignoreOpt) - bg := NewBackground(10, &RedisOpt{ + bg := NewBackground(10, &RedisConfig{ Addr: "localhost:6379", DB: 15, }) - client := NewClient(&RedisOpt{ + client := NewClient(&RedisConfig{ Addr: "localhost:6379", DB: 15, }) diff --git a/client.go b/client.go index 0e8454f..d98f7ed 100644 --- a/client.go +++ b/client.go @@ -12,8 +12,8 @@ type Client struct { } // NewClient creates and returns a new client. -func NewClient(opt *RedisOpt) *Client { - return &Client{rdb: newRDB(opt)} +func NewClient(config *RedisConfig) *Client { + return &Client{rdb: newRDB(config)} } // Process enqueues the task to be performed at a given time. diff --git a/rdb.go b/rdb.go index e5fc337..03ae997 100644 --- a/rdb.go +++ b/rdb.go @@ -28,11 +28,11 @@ type rdb struct { client *redis.Client } -func newRDB(opt *RedisOpt) *rdb { +func newRDB(config *RedisConfig) *rdb { client := redis.NewClient(&redis.Options{ - Addr: opt.Addr, - Password: opt.Password, - DB: opt.DB, + Addr: config.Addr, + Password: config.Password, + DB: config.DB, }) return &rdb{client} }