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/main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'backend/main.go') diff --git a/backend/main.go b/backend/main.go index e2e4bbd..a213c6c 100644 --- a/backend/main.go +++ b/backend/main.go @@ -15,6 +15,7 @@ import ( "github.com/nsfisis/iosdc-japan-2024-albatross/backend/api" "github.com/nsfisis/iosdc-japan-2024-albatross/backend/db" "github.com/nsfisis/iosdc-japan-2024-albatross/backend/game" + "github.com/nsfisis/iosdc-japan-2024-albatross/backend/taskqueue" ) func connectDB(ctx context.Context, dsn string) (*pgxpool.Pool, error) { @@ -59,7 +60,10 @@ func main() { e.Use(middleware.Logger()) e.Use(middleware.Recover()) - gameHubs := game.NewGameHubs(queries) + taskQueue := taskqueue.NewQueue("task-db:6379") + workerServer := taskqueue.NewWorkerServer("task-db:6379") + + gameHubs := game.NewGameHubs(queries, taskQueue) err = gameHubs.RestoreFromDB(ctx) if err != nil { log.Fatalf("Error restoring game hubs from db %v", err) @@ -94,6 +98,10 @@ func main() { gameHubs.Run() + go func() { + workerServer.Run() + }() + if err := e.Start(":80"); err != http.ErrServerClosed { log.Fatal(err) } -- cgit v1.2.3-70-g09d2