Skip to content

Commit

Permalink
✨ Check the redis config (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
tosone authored Jun 23, 2024
1 parent ed67cc1 commit 1a471a3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/modules/cacher/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/go-sigma/sigma/pkg/configs"
"github.com/go-sigma/sigma/pkg/modules/cacher/definition"
"github.com/go-sigma/sigma/pkg/types/enums"
)

type cacher[T any] struct {
Expand All @@ -35,6 +36,9 @@ type cacher[T any] struct {

// New returns a new Cacher.
func New[T any](config configs.Configuration, prefix string, fetcher definition.Fetcher[T]) (definition.Cacher[T], error) {
if config.Redis.Type != enums.RedisTypeExternal {
return nil, fmt.Errorf("cacher: please check redis configuration, it should be external")
}
redisOpt, err := redis.ParseURL(config.Redis.Url)
if err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions pkg/modules/workq/redis/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import (

// NewWorkQueueConsumer ...
func NewWorkQueueConsumer(config configs.Configuration, topicHandlers map[enums.Daemon]definition.Consumer) error {
if config.Redis.Type != enums.RedisTypeExternal {
return fmt.Errorf("work queue: please check redis configuration, it should be external")
}
redisOpt, err := asynq.ParseRedisURI(config.Redis.Url)
if err != nil {
return fmt.Errorf("asynq.ParseRedisURI error: %v", err)
Expand Down
3 changes: 3 additions & 0 deletions pkg/modules/workq/redis/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ type producer struct {

// NewWorkQueueProducer ...
func NewWorkQueueProducer(config configs.Configuration, topicHandlers map[enums.Daemon]definition.Consumer) (definition.WorkQueueProducer, error) {
if config.Redis.Type != enums.RedisTypeExternal {
return nil, fmt.Errorf("work queue: please check redis configuration, it should be external")
}
redisOpt, err := asynq.ParseRedisURI(config.Redis.Url)
if err != nil {
return nil, fmt.Errorf("asynq.ParseRedisURI error: %v", err)
Expand Down

0 comments on commit 1a471a3

Please sign in to comment.