test: add document process task options tests
Centralize DefaultDocumentProcessTimeout in the config package and reuse DocumentProcessTimeout() from documentProcessTaskOptions.
This commit is contained in:
@@ -1,23 +1,14 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/config"
|
||||
"github.com/hibiken/asynq"
|
||||
)
|
||||
|
||||
func documentProcessTaskOptions(cfg *config.Config, extra ...asynq.Option) []asynq.Option {
|
||||
timeout := 2 * time.Hour
|
||||
if cfg != nil &&
|
||||
cfg.KnowledgeBase != nil &&
|
||||
cfg.KnowledgeBase.DocumentProcessTimeout > 0 {
|
||||
timeout = cfg.KnowledgeBase.DocumentProcessTimeout
|
||||
}
|
||||
|
||||
opts := []asynq.Option{
|
||||
asynq.Queue("default"),
|
||||
asynq.Timeout(timeout),
|
||||
asynq.Timeout(config.DocumentProcessTimeout(cfg)),
|
||||
}
|
||||
opts = append(opts, extra...)
|
||||
return opts
|
||||
|
||||
Reference in New Issue
Block a user