blob: db05553212496c7197a2f4715e13020467af3cf3 (
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 (
"encoding/json"
"github.com/hibiken/asynq"
)
const (
TaskTypeExec = "exec"
)
type TaskExecPlayload struct {
GameID int
UserID int
Code string
}
func NewExecTask(gameID, userID int, code string) (*asynq.Task, error) {
payload, err := json.Marshal(TaskExecPlayload{
GameID: gameID,
UserID: userID,
Code: code,
})
if err != nil {
return nil, err
}
return asynq.NewTask(TaskTypeExec, payload), nil
}
type TaskExecResult struct {
Task *TaskExecPlayload
Result string
Stdout string
Stderr string
}
|