diff options
Diffstat (limited to 'backend/taskqueue/tasks.go')
| -rw-r--r-- | backend/taskqueue/tasks.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/backend/taskqueue/tasks.go b/backend/taskqueue/tasks.go new file mode 100644 index 0000000..cd67948 --- /dev/null +++ b/backend/taskqueue/tasks.go @@ -0,0 +1,29 @@ +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 +} |
