diff options
Diffstat (limited to 'backend/taskqueue/worker_server.go')
| -rw-r--r-- | backend/taskqueue/worker_server.go | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/backend/taskqueue/worker_server.go b/backend/taskqueue/worker_server.go index 67803e2..6dc65d8 100644 --- a/backend/taskqueue/worker_server.go +++ b/backend/taskqueue/worker_server.go @@ -7,31 +7,35 @@ import ( ) type WorkerServer struct { - server *asynq.Server - queries *db.Queries - results chan TaskExecResult + server *asynq.Server + processor *processor } func NewWorkerServer(redisAddr string, queries *db.Queries) *WorkerServer { + server := asynq.NewServer( + asynq.RedisClientOpt{ + Addr: redisAddr, + }, + asynq.Config{}, + ) + processor := newProcessor(queries) return &WorkerServer{ - server: asynq.NewServer( - asynq.RedisClientOpt{ - Addr: redisAddr, - }, - asynq.Config{}, - ), - queries: queries, - results: make(chan TaskExecResult), + server: server, + processor: processor, } } func (s *WorkerServer) Run() error { mux := asynq.NewServeMux() - mux.Handle(TaskTypeExec, NewExecProcessor(s.queries, s.results)) + + mux.HandleFunc(string(TaskTypeCreateSubmissionRecord), s.processor.processTaskCreateSubmissionRecord) + mux.HandleFunc(string(TaskTypeCompileSwiftToWasm), s.processor.processTaskCompileSwiftToWasm) + mux.HandleFunc(string(TaskTypeCompileWasmToNativeExecutable), s.processor.processTaskCompileWasmToNativeExecutable) + mux.HandleFunc(string(TaskTypeRunTestcase), s.processor.processTaskRunTestcase) return s.server.Run(mux) } -func (s *WorkerServer) Results() chan TaskExecResult { - return s.results +func (s *WorkerServer) Results() chan TaskResult { + return s.processor.results } |
