aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/taskqueue/queue.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/queue.go
parent9ff9c151e5defd9eed5cba3c88bc341b4360d09c (diff)
downloadiosdc-japan-2025-albatross-296aa3f8a145a8fbc08db9f5b1d45fe6f72a38a4.tar.gz
iosdc-japan-2025-albatross-296aa3f8a145a8fbc08db9f5b1d45fe6f72a38a4.tar.zst
iosdc-japan-2025-albatross-296aa3f8a145a8fbc08db9f5b1d45fe6f72a38a4.zip
feat: implement task queue
Diffstat (limited to 'backend/taskqueue/queue.go')
-rw-r--r--backend/taskqueue/queue.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/backend/taskqueue/queue.go b/backend/taskqueue/queue.go
new file mode 100644
index 0000000..53ec6d6
--- /dev/null
+++ b/backend/taskqueue/queue.go
@@ -0,0 +1,25 @@
+package taskqueue
+
+import (
+ "github.com/hibiken/asynq"
+)
+
+type Queue struct {
+ client *asynq.Client
+}
+
+func NewQueue(redisAddr string) *Queue {
+ return &Queue{
+ client: asynq.NewClient(asynq.RedisClientOpt{
+ Addr: redisAddr,
+ }),
+ }
+}
+
+func (q *Queue) Close() {
+ q.client.Close()
+}
+
+func (q *Queue) Enqueue(task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error) {
+ return q.client.Enqueue(task, opts...)
+}