From 296aa3f8a145a8fbc08db9f5b1d45fe6f72a38a4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 5 Aug 2024 03:57:21 +0900 Subject: feat: implement task queue --- backend/taskqueue/processor.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 backend/taskqueue/processor.go (limited to 'backend/taskqueue/processor.go') diff --git a/backend/taskqueue/processor.go b/backend/taskqueue/processor.go new file mode 100644 index 0000000..e26ac64 --- /dev/null +++ b/backend/taskqueue/processor.go @@ -0,0 +1,25 @@ +package taskqueue + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/hibiken/asynq" +) + +type ExecProcessor struct { +} + +func (processor *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error { + var payload TaskExecPlayload + if err := json.Unmarshal(t.Payload(), &payload); err != nil { + return fmt.Errorf("json.Unmarshal failed: %v: %w", err, asynq.SkipRetry) + } + // TODO + return nil +} + +func NewExecProcessor() *ExecProcessor { + return &ExecProcessor{} +} -- cgit v1.2.3-70-g09d2