aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/taskqueue/worker_server.go
blob: 9bdd81f1cbd956fa2b3363d4d6cf4c5cd2d45f7b (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
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)
}