blob: 7effba7cd929d3c9c46754e9cdb27d2756b559c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package taskqueue
import (
"github.com/hibiken/asynq"
)
type WorkerServer struct {
server *asynq.Server
processor *processorWrapper
}
func NewWorkerServer(redisAddr string) *WorkerServer {
server := asynq.NewServer(
asynq.RedisClientOpt{
Addr: redisAddr,
},
asynq.Config{},
)
processor := newProcessorWrapper(newProcessor())
return &WorkerServer{
server: server,
processor: processor,
}
}
func (s *WorkerServer) Run() error {
mux := asynq.NewServeMux()
mux.HandleFunc(string(TaskTypeRunTestcase), s.processor.processTaskRunTestcase)
return s.server.Run(mux)
}
func (s *WorkerServer) Results() chan TaskResult {
return s.processor.results
}
|