aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/taskqueue/worker_server.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-07 23:49:10 +0900
committernsfisis <nsfisis@gmail.com>2024-08-08 04:02:37 +0900
commitcfe46bf104dec03c81ca38eb6b6a23b372a271b6 (patch)
tree083ecee8ff2576772efc15501594ab0ff1e122be /backend/taskqueue/worker_server.go
parent47d81ffbd3e4fe178d2935325e312cef77276250 (diff)
downloadiosdc-japan-2025-albatross-cfe46bf104dec03c81ca38eb6b6a23b372a271b6.tar.gz
iosdc-japan-2025-albatross-cfe46bf104dec03c81ca38eb6b6a23b372a271b6.tar.zst
iosdc-japan-2025-albatross-cfe46bf104dec03c81ca38eb6b6a23b372a271b6.zip
feat(backend): split task into smaller task types
Diffstat (limited to 'backend/taskqueue/worker_server.go')
-rw-r--r--backend/taskqueue/worker_server.go32
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
}