2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-24 23:02:18 +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
}
// RedisOpt specifies redis options.
type RedisOpt struct {
// RedisConfig specifies redis configurations.
type RedisConfig struct {
Addr string
Password string

View File

@ -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
})

View File

@ -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{

View File

@ -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,
})

View File

@ -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.

8
rdb.go
View File

@ -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}
}