18 lines
442 B
Go
18 lines
442 B
Go
package queue
|
|
|
|
import (
|
|
"juhe-factory/api/internal/config"
|
|
|
|
"github.com/hibiken/asynq"
|
|
)
|
|
|
|
func NewServer(cfg config.Config) *asynq.Server {
|
|
concurrency := cfg.AIWorkerConcurrency
|
|
if concurrency < 1 {
|
|
concurrency = 1
|
|
}
|
|
return asynq.NewServer(asynq.RedisClientOpt{
|
|
Addr: cfg.RedisAddress, Password: cfg.RedisPassword, DB: cfg.AsynqRedisDB,
|
|
}, asynq.Config{Concurrency: concurrency, Queues: map[string]int{"ai": 10, "default": 1}})
|
|
}
|