blob: 5c518f4cf595f98610f9aa387a3123fb663c1ed2 (
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
Status string
Stdout string
Stderr string
}
|