Skip to content

Commit 3c562f6

Browse files
Refactor Redis configuration; add RedisPassword to Config struct and update NewClient and NewServer functions
1 parent 991c58f commit 3c562f6

4 files changed

Lines changed: 11 additions & 6 deletions

File tree

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@
77
tmp/
88
coverage/
99

10-
README.md
10+
README.md
11+
12+
assets/

internal/config/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import (
77
)
88

99
type Config struct {
10-
RedisHost string
11-
RedisPort string
10+
RedisHost string
11+
RedisPort string
12+
RedisPassword string
1213

1314
AWSRegion string
1415
AWSAccessKeyID string

internal/queue/redis.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010

1111
func NewClient(cfg *config.Config) *redis.Client {
1212
return redis.NewClient(&redis.Options{
13-
Addr: fmt.Sprintf("%s:%s", cfg.RedisHost, cfg.RedisPort),
13+
Addr: fmt.Sprintf("%s:%s", cfg.RedisHost, cfg.RedisPort),
14+
Password: cfg.RedisPassword,
1415
})
1516
}
1617

internal/queue/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import (
1010
func NewServer(cfg *config.Config) *asynq.Server {
1111
return asynq.NewServer(
1212
asynq.RedisClientOpt{
13-
Addr: fmt.Sprintf("%s:%s", cfg.RedisHost, cfg.RedisPort),
13+
Addr: fmt.Sprintf("%s:%s", cfg.RedisHost, cfg.RedisPort),
14+
Password: cfg.RedisPassword,
1415
},
1516
asynq.Config{
16-
Concurrency: 5,
17+
Concurrency: 3,
1718
},
1819
)
1920
}

0 commit comments

Comments
 (0)