aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/taskqueue/worker_server.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/taskqueue/worker_server.go')
-rw-r--r--backend/taskqueue/worker_server.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/backend/taskqueue/worker_server.go b/backend/taskqueue/worker_server.go
new file mode 100644
index 0000000..9bdd81f
--- /dev/null
+++ b/backend/taskqueue/worker_server.go
@@ -0,0 +1,27 @@
+package taskqueue
+
+import (
+ "github.com/hibiken/asynq"
+)
+
+type WorkerServer struct {
+ server *asynq.Server
+}
+
+func NewWorkerServer(redisAddr string) *WorkerServer {
+ return &WorkerServer{
+ server: asynq.NewServer(
+ asynq.RedisClientOpt{
+ Addr: redisAddr,
+ },
+ asynq.Config{},
+ ),
+ }
+}
+
+func (s *WorkerServer) Run() error {
+ mux := asynq.NewServeMux()
+ mux.Handle(TaskTypeExec, NewExecProcessor())
+
+ return s.server.Run(mux)
+}