aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/taskqueue/tasks.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-05 03:57:21 +0900
committernsfisis <nsfisis@gmail.com>2024-08-05 03:57:21 +0900
commit296aa3f8a145a8fbc08db9f5b1d45fe6f72a38a4 (patch)
tree11180e08e96e1adb492b3aa52d32edd79a669711 /backend/taskqueue/tasks.go
parent9ff9c151e5defd9eed5cba3c88bc341b4360d09c (diff)
downloadiosdc-japan-2024-albatross-296aa3f8a145a8fbc08db9f5b1d45fe6f72a38a4.tar.gz
iosdc-japan-2024-albatross-296aa3f8a145a8fbc08db9f5b1d45fe6f72a38a4.tar.zst
iosdc-japan-2024-albatross-296aa3f8a145a8fbc08db9f5b1d45fe6f72a38a4.zip
feat: implement task queue
Diffstat (limited to 'backend/taskqueue/tasks.go')
-rw-r--r--backend/taskqueue/tasks.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/backend/taskqueue/tasks.go b/backend/taskqueue/tasks.go
new file mode 100644
index 0000000..2891a36
--- /dev/null
+++ b/backend/taskqueue/tasks.go
@@ -0,0 +1,32 @@
+package taskqueue
+
+import (
+ "encoding/json"
+
+ "github.com/hibiken/asynq"
+)
+
+const (
+ TaskTypeExec = "exec"
+)
+
+type Testcase struct {
+ Stdin string
+ Stdout string
+}
+
+type TaskExecPlayload struct {
+ Code string
+ Testcases []*Testcase
+}
+
+func NewExecTask(code string, testcases []*Testcase) (*asynq.Task, error) {
+ payload, err := json.Marshal(TaskExecPlayload{
+ Code: code,
+ Testcases: testcases,
+ })
+ if err != nil {
+ return nil, err
+ }
+ return asynq.NewTask(TaskTypeExec, payload), nil
+}