From 94c8d6ba37b2c8f74912981c26408727b62c5eea Mon Sep 17 00:00:00 2001 From: GRACENOBLE Date: Mon, 15 Jun 2026 18:21:00 +0300 Subject: [PATCH] feat(queue): integrate Asynq + Redis Streams for background jobs and events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a full background-job and event-streaming layer backed by the existing Redis instance (REDIS_URL) — no new env vars required. - usecase.Enqueuer interface (Enqueue + Close) in usecase/enqueuer.go - internal/infrastructure/queue/: Asynq client, worker, task constants, WelcomeEmail handler stub (real delivery wired in #20) - internal/infrastructure/streams/: Redis Streams producer + consumer-group consumer for event fan-out (user.created, notification.sent) - bootstrap.App gains an Enqueuer field (nil when REDIS_URL is unset) - Handler struct gains enqueuer + queueUI fields; Asynqmon UI mounts at /admin/queues in debug mode when Redis is available - Worker goroutine wired in main.go following the ws.Hub pattern; cancelled before hub on graceful shutdown - Queue unit tests (handlers_test.go) run without Docker; integration test skips gracefully when Docker is unavailable - Stale docs fixed: routing.md (NewServer signature + /metrics route), middleware.md (SentryMiddleware + PrometheusMiddleware order) - New docs: backend/docs/queue.md, backend/docs/streams.md Closes #18 Co-Authored-By: Claude Sonnet 4.6 --- backend/cmd/api/main.go | 29 +++ backend/docs/_index.md | 2 + backend/docs/middleware.md | 18 +- backend/docs/queue.md | 206 ++++++++++++++++ backend/docs/routing.md | 11 +- backend/docs/streams.md | 159 ++++++++++++ backend/docs/swagger/docs.go | 19 ++ backend/docs/swagger/swagger.json | 19 ++ backend/docs/swagger/swagger.yaml | 12 + backend/go.mod | 5 + backend/go.sum | 230 ++++++++++++++++++ backend/internal/bootstrap/bootstrap.go | 12 + .../internal/infrastructure/queue/client.go | 42 ++++ .../infrastructure/queue/client_test.go | 74 ++++++ .../internal/infrastructure/queue/handlers.go | 21 ++ .../infrastructure/queue/handlers_test.go | 29 +++ .../internal/infrastructure/queue/tasks.go | 13 + .../internal/infrastructure/queue/worker.go | 67 +++++ .../infrastructure/streams/consumer.go | 76 ++++++ .../internal/infrastructure/streams/events.go | 13 + .../infrastructure/streams/producer.go | 40 +++ .../infrastructure/streams/producer_test.go | 93 +++++++ backend/internal/server/server.go | 22 +- .../internal/transport/handlers/handler.go | 20 +- .../transport/handlers/health_handler_test.go | 4 +- .../transport/handlers/queue_handler.go | 13 + backend/internal/transport/handlers/routes.go | 6 + backend/internal/usecase/enqueuer.go | 11 + 28 files changed, 1249 insertions(+), 17 deletions(-) create mode 100644 backend/docs/queue.md create mode 100644 backend/docs/streams.md create mode 100644 backend/internal/infrastructure/queue/client.go create mode 100644 backend/internal/infrastructure/queue/client_test.go create mode 100644 backend/internal/infrastructure/queue/handlers.go create mode 100644 backend/internal/infrastructure/queue/handlers_test.go create mode 100644 backend/internal/infrastructure/queue/tasks.go create mode 100644 backend/internal/infrastructure/queue/worker.go create mode 100644 backend/internal/infrastructure/streams/consumer.go create mode 100644 backend/internal/infrastructure/streams/events.go create mode 100644 backend/internal/infrastructure/streams/producer.go create mode 100644 backend/internal/infrastructure/streams/producer_test.go create mode 100644 backend/internal/transport/handlers/queue_handler.go create mode 100644 backend/internal/usecase/enqueuer.go diff --git a/backend/cmd/api/main.go b/backend/cmd/api/main.go index 4350a20..79a8f8c 100644 --- a/backend/cmd/api/main.go +++ b/backend/cmd/api/main.go @@ -10,7 +10,10 @@ import ( "syscall" "time" + "github.com/hibiken/asynq" + "backend/internal/bootstrap" + "backend/internal/infrastructure/queue" "backend/internal/infrastructure/ws" "backend/internal/server" ) @@ -60,6 +63,23 @@ func main() { hub := ws.NewHub() go hub.Run(hubCtx) + var workerCancel context.CancelFunc + if app.Config.RedisURL != "" { + workerCtx, wCancel := context.WithCancel(context.Background()) + workerCancel = wCancel + worker, err := queue.NewWorker(app.Config.RedisURL) + if err != nil { + fmt.Fprintf(os.Stderr, "startup failed: %v\n", err) + os.Exit(1) + } + worker.Register(queue.TypeWelcomeEmail, asynq.HandlerFunc(queue.HandleWelcomeEmail)) + go func() { + if err := worker.Run(workerCtx); err != nil { + slog.Error("queue: worker error", "err", err) + } + }() + } + srv, err := server.NewServer(app, hub) if err != nil { fmt.Fprintf(os.Stderr, "startup failed: %v\n", err) @@ -75,6 +95,10 @@ func main() { } <-done + + if workerCancel != nil { + workerCancel() // stop worker before hub (in-flight jobs drain first) + } hubCancel() // stop hub after all WS connections have been closed by server shutdown if app.Cache != nil { @@ -82,5 +106,10 @@ func main() { slog.Error("cache close error", "error", err) } } + if app.Enqueuer != nil { + if err := app.Enqueuer.Close(); err != nil { + slog.Error("enqueuer close error", "error", err) + } + } slog.Info("graceful shutdown complete") } diff --git a/backend/docs/_index.md b/backend/docs/_index.md index 17b8974..52b3b15 100644 --- a/backend/docs/_index.md +++ b/backend/docs/_index.md @@ -16,3 +16,5 @@ The `docs` agent reads this index first to locate the right file before diving i | Firebase Auth (token verification, middleware, MeHandler) | [auth.md](auth.md) | `internal/usecase/auth_usecase.go`, `internal/transport/middleware/auth.go`, `internal/transport/handlers/auth_handler.go`, `pkg/firebase/admin.go`, `internal/bootstrap/bootstrap.go` | | Observability (Sentry error tracking) | [observability.md](observability.md) | `internal/transport/middleware/sentry.go`, `internal/bootstrap/bootstrap.go`, `internal/transport/handlers/routes.go` | | WebSocket (Hub, client, GET /ws, auth, wiring) | [websocket.md](websocket.md) | `internal/infrastructure/ws/`, `internal/transport/handlers/ws_handler.go`, `internal/transport/handlers/routes.go`, `internal/server/server.go`, `cmd/api/main.go` | +| Background job queue (Asynq, task definitions, worker, Asynqmon UI) | [queue.md](queue.md) | `internal/usecase/enqueuer.go`, `internal/infrastructure/queue/tasks.go`, `internal/infrastructure/queue/client.go`, `internal/infrastructure/queue/worker.go`, `internal/infrastructure/queue/handlers.go`, `internal/transport/handlers/routes.go`, `cmd/api/main.go` | +| Redis Streams event fan-out (producer, consumer, consumer groups) | [streams.md](streams.md) | `internal/infrastructure/streams/events.go`, `internal/infrastructure/streams/producer.go`, `internal/infrastructure/streams/consumer.go` | diff --git a/backend/docs/middleware.md b/backend/docs/middleware.md index d914634..22320d7 100644 --- a/backend/docs/middleware.md +++ b/backend/docs/middleware.md @@ -15,11 +15,15 @@ All middleware lives in `internal/transport/middleware/` and follows the Gin `Ha ## Registration order ```go -// 1. Recovery + logger (debug: gin.Logger, release: middleware.Logger) +// 1. Sentry error reporting +r.Use(middleware.SentryMiddleware(sentryDSN)) +// 2. Recovery + logger (debug: gin.Logger, release: middleware.Logger) r.Use(gin.Recovery(), middleware.Logger()) -// 2. Rate limiter (no-op when RPS <= 0) +// 3. Prometheus metrics collection +r.Use(middleware.PrometheusMiddleware()) +// 4. Rate limiter (no-op when RPS <= 0) r.Use(middleware.RateLimit(rps, burst)) -// 3. CORS +// 5. CORS r.Use(cors.New(...)) // Global routes (no auth): @@ -27,10 +31,10 @@ r.GET("/", h.HelloWorldHandler) r.GET("/health", h.HealthHandler) r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) -// Protected group — FirebaseAuth applied when verifier != nil: +// Protected group — FirebaseAuth applied when h.verifier != nil: api := r.Group("/api/v1") -if verifier != nil { - api.Use(middleware.FirebaseAuth(verifier)) +if h.verifier != nil { + api.Use(middleware.FirebaseAuth(h.verifier)) } api.GET("/me", h.MeHandler) ``` @@ -71,7 +75,7 @@ val, _ := c.Get(middleware.FirebaseClaimsKey) token, ok := val.(*usecase.FirebaseToken) ``` -Pass `nil` as the `verifier` to `RegisterRoutes` to skip Firebase auth entirely (development without credentials). +Pass `nil` as the `verifier` to `NewHandler` to skip Firebase auth entirely (development without credentials). `RegisterRoutes` reads `h.verifier` from the struct — it is not a parameter of `RegisterRoutes`. ## Adding new middleware diff --git a/backend/docs/queue.md b/backend/docs/queue.md new file mode 100644 index 0000000..abc6129 --- /dev/null +++ b/backend/docs/queue.md @@ -0,0 +1,206 @@ +--- +topic: queue +last_verified: 2026-06-15 +sources: + - internal/usecase/enqueuer.go + - internal/infrastructure/queue/tasks.go + - internal/infrastructure/queue/client.go + - internal/infrastructure/queue/worker.go + - internal/infrastructure/queue/handlers.go + - internal/transport/handlers/routes.go + - cmd/api/main.go +--- + +# Queue (Asynq) + +## Overview + +Background jobs are processed by [Asynq](https://github.com/hibiken/asynq), which uses +Redis as its broker. The same `REDIS_URL` env var used by the cache layer is reused — no +additional env vars are required. When `REDIS_URL` is not set, `app.Enqueuer` is `nil` +and no worker is started; the rest of the application continues normally. + +Asynq handles discrete, retriable background jobs (welcome emails, notifications, +webhooks). For ordered event fan-out between services see `backend/docs/streams.md`. + +## Task definitions + +Task type constants and payload structs are co-located in +`internal/infrastructure/queue/tasks.go`: + +```go +const ( + TypeWelcomeEmail = "email:welcome" +) + +type WelcomeEmailPayload struct { + UserID string `json:"user_id"` + Email string `json:"email"` +} +``` + +Both the enqueuer (caller side) and the handler (worker side) import these constants so +the string is never duplicated. + +## Enqueuer interface + +`internal/usecase/enqueuer.go` defines the port that use cases and handlers depend on: + +```go +type Enqueuer interface { + Enqueue(ctx context.Context, taskType string, payload []byte) error + Close() error +} +``` + +The concrete implementation is created with `queue.NewClient`: + +```go +// internal/infrastructure/queue/client.go +func NewClient(redisURL string) (usecase.Enqueuer, error) +``` + +`NewClient` parses `redisURL` using `go-redis/v9`'s `ParseURL`, constructs an +`asynq.Client`, and returns it wrapped as a `usecase.Enqueuer`. + +### Enqueueing from a use case or handler + +```go +payload, err := json.Marshal(queue.WelcomeEmailPayload{ + UserID: userID, + Email: email, +}) +if err != nil { + return err +} +if app.Enqueuer != nil { + if err := app.Enqueuer.Enqueue(ctx, queue.TypeWelcomeEmail, payload); err != nil { + return err + } +} +``` + +Guard with `!= nil` because `app.Enqueuer` is nil when `REDIS_URL` is unset. + +### Bootstrap wiring + +`app.Enqueuer` is populated by `bootstrap.Run` when `REDIS_URL` is set (see +`internal/bootstrap/bootstrap.go`). After the HTTP server shuts down, `main.go` calls +`app.Enqueuer.Close()` to release the connection. + +## Worker setup + +`internal/infrastructure/queue/worker.go` + +```go +func NewWorker(redisURL string) (*Worker, error) +func (w *Worker) Register(taskType string, h asynq.Handler) +func (w *Worker) Run(ctx context.Context) error // blocking; cancel ctx to stop +``` + +`NewWorker` creates an `asynq.Server` with `Concurrency: 10`. Failed tasks are logged via +`slog.Error` through the server's `ErrorHandler`. + +`Run` starts the server in an inner goroutine and blocks until either `ctx` is cancelled +(clean shutdown via `w.server.Shutdown()`) or the server returns an error. + +### Goroutine wiring in cmd/api/main.go + +The worker is started only when `REDIS_URL` is set, using a child context so it can be +cancelled independently of the hub: + +```go +var workerCancel context.CancelFunc +if app.Config.RedisURL != "" { + workerCtx, wCancel := context.WithCancel(context.Background()) + workerCancel = wCancel + worker, err := queue.NewWorker(app.Config.RedisURL) + // ... + worker.Register(queue.TypeWelcomeEmail, asynq.HandlerFunc(queue.HandleWelcomeEmail)) + go func() { + if err := worker.Run(workerCtx); err != nil { + slog.Error("queue: worker error", "err", err) + } + }() +} +``` + +Shutdown order after `<-done`: + +```go +if workerCancel != nil { + workerCancel() // stop worker before hub (in-flight jobs drain first) +} +hubCancel() +``` + +The worker is cancelled before the hub so that any task handler that calls `hub.Publish` +can still reach the hub during drain. + +## Task handlers + +Handler functions have the signature `func(context.Context, *asynq.Task) error` and live +in `internal/infrastructure/queue/handlers.go`: + +```go +func HandleWelcomeEmail(_ context.Context, t *asynq.Task) error { + var p WelcomeEmailPayload + if err := json.Unmarshal(t.Payload(), &p); err != nil { + return fmt.Errorf("welcome email: unmarshal payload: %w", err) + } + slog.Info("queue: welcome email task received", "user_id", p.UserID, "email", p.Email) + return nil +} +``` + +Returning a non-nil error causes Asynq to retry the task (up to its configured retry limit). + +## Adding a new task + +1. Add a `Type = ":"` constant and `Payload` struct to + `internal/infrastructure/queue/tasks.go`. +2. Write a `Handle(ctx context.Context, t *asynq.Task) error` function in + `internal/infrastructure/queue/handlers.go`. +3. Register the handler in `cmd/api/main.go`: + ```go + worker.Register(queue.Type, asynq.HandlerFunc(queue.Handle)) + ``` +4. Enqueue from the relevant use case or handler using `app.Enqueuer.Enqueue(ctx, queue.Type, payload)`. + +## Asynqmon UI + +When running in `gin.DebugMode` and `REDIS_URL` is set, the Asynqmon job-monitoring UI is +available at: + +``` +http://localhost:8080/admin/queues +``` + +Routes are registered in `RegisterRoutes` only under these conditions: + +```go +if gin.Mode() == gin.DebugMode && h.queueUI != nil { + r.GET("/admin/queues", gin.WrapH(h.queueUI)) + r.Any("/admin/queues/*path", gin.WrapH(h.queueUI)) +} +``` + +The UI is not mounted in staging or production (`gin.ReleaseMode`). + +## Testing + +**Unit tests** call handler functions directly with `asynq.NewTask` — no Redis required: + +```go +payload, _ := json.Marshal(queue.WelcomeEmailPayload{UserID: "u1", Email: "a@b.com"}) +task := asynq.NewTask(queue.TypeWelcomeEmail, payload) +err := queue.HandleWelcomeEmail(context.Background(), task) +// assert err == nil +``` + +**Integration tests** use Testcontainers Redis (same `TestMain` pattern as +`internal/infrastructure/cache/redis/cache_test.go`). The `TestMain` function skips +integration tests gracefully when Docker is unavailable so that unit tests still run. + +Enqueuer integration tests construct a real `queue.NewClient`, enqueue a task, and use +`asynq.NewInspector` (via `queue.NewInspector`) to verify the task appears in the queue. diff --git a/backend/docs/routing.md b/backend/docs/routing.md index b18fd20..87093df 100644 --- a/backend/docs/routing.md +++ b/backend/docs/routing.md @@ -30,8 +30,8 @@ func NewHandler(healthUC usecase.HealthUseCase, verifier usecase.FirebaseTokenVe The `Handler` struct holds use case interfaces and infrastructure dependencies — not `*sql.DB` directly. `verifier` is stored on the struct (not passed to `RegisterRoutes`) so the WebSocket handler can read it inline for query-param auth. ## Wiring (server.go) -`internal/server/server.go` contains `NewServer(app *bootstrap.App) *http.Server` — wiring only, no logic. -It receives the already-validated `*bootstrap.App` (which holds `*sql.DB`, `Cache`, `Firebase`, and `Config`), constructs the repository, use case, and handler in order, then returns a configured `*http.Server`. It does not read env vars or return an error. +`internal/server/server.go` contains `NewServer(app *bootstrap.App, hub *ws.Hub) (*http.Server, error)` — wiring only, no logic. +It receives the already-validated `*bootstrap.App` (which holds `*sql.DB`, `Cache`, `Firebase`, and `Config`) and a `*ws.Hub`, constructs the repository, use case, and handler in order, then returns a configured `*http.Server`. Errors from initialisation steps are returned to the caller. ```go healthRepo := postgres.NewHealthRepository(app.DB) @@ -44,13 +44,13 @@ return &http.Server{ IdleTimeout: time.Minute, ReadTimeout: 10 * time.Second, WriteTimeout: 30 * time.Second, -} +}, nil ``` ## Route registration All routes registered in `RegisterRoutes()` on `*Handler`, which returns `http.Handler`. `rps` and `burst` come from `bootstrap.Config` (env vars `RATE_LIMIT_RPS` / `RATE_LIMIT_BURST`); pass `rps=0` to disable. -`verifier` is a `usecase.FirebaseTokenVerifier`; pass `nil` to skip Firebase auth (development only — see [auth](auth.md)). +`h.verifier` (set via `NewHandler`) controls Firebase auth — the verifier is read from the struct, not passed to `RegisterRoutes`; a `nil` verifier skips Firebase auth (development only — see [auth](auth.md)). ```go func (h *Handler) RegisterRoutes(rps float64, burst int, sentryDSN string) http.Handler { @@ -109,13 +109,14 @@ Allowed methods: GET, POST, PUT, DELETE, OPTIONS, PATCH. | GET | `/` | none | `HelloWorldHandler` — returns `{"message": "Hello World"}` | `hello_handler.go` | | GET | `/health` | none | `HealthHandler` — returns `HealthStats`; 503 when DB is down | `health_handler.go` | | GET | `/ws` | `?token=` query param | `WsHandler` — upgrades to WebSocket; 401 when token missing/invalid | `ws_handler.go` | +| GET | `/metrics` | `LocalNetworkOnly()` | Prometheus scrape endpoint; restricted to loopback/RFC 1918 in staging/production | `metrics_handler.go` | | GET | `/api/v1/me` | FirebaseAuth header | `MeHandler` — returns verified `FirebaseToken` claims | `auth_handler.go` | ## Graceful shutdown Wired in `cmd/api/main.go` via `signal.NotifyContext` for SIGINT/SIGTERM. 5-second shutdown timeout. Server notifies `done chan bool` when complete. `main()` calls `bootstrap.Run(ctx)` first; on failure it writes to stderr and calls `os.Exit(1)`. -`server.NewServer` does not return an error — all fallible startup work is in bootstrap. +`server.NewServer` returns `(*http.Server, error)` — the caller in `cmd/api/main.go` checks the error and exits on failure. Do not add shutdown logic to `internal/` — it belongs in `cmd/`. ## Adding a new route — checklist diff --git a/backend/docs/streams.md b/backend/docs/streams.md new file mode 100644 index 0000000..b2b4c36 --- /dev/null +++ b/backend/docs/streams.md @@ -0,0 +1,159 @@ +--- +topic: streams +last_verified: 2026-06-15 +sources: + - internal/infrastructure/streams/events.go + - internal/infrastructure/streams/producer.go + - internal/infrastructure/streams/consumer.go +--- + +# Redis Streams + +## Overview + +Redis Streams provide an ordered, persistent event log for event-driven fan-out between +services. The same `REDIS_URL` env var used by the cache and queue layers is reused — no +additional env vars are required. + +Streams complement Asynq rather than replace it: + +| Concern | Mechanism | +|---|---| +| Discrete retriable background jobs | Asynq (`backend/docs/queue.md`) | +| Ordered event log / fan-out to multiple consumers | Redis Streams (`this file`) | + +All Streams code lives in `internal/infrastructure/streams/`. + +## Stream names + +Stream name constants and event payload structs are defined in +`internal/infrastructure/streams/events.go`: + +```go +const ( + StreamUserCreated = "stream:user.created" + StreamNotificationSent = "stream:notification.sent" +) + +type UserCreatedEvent struct { + UserID string `json:"user_id"` + Email string `json:"email"` +} +``` + +Naming convention: `stream:.` — all lowercase, dot separator between +domain noun and past-tense verb. + +## Publishing events + +`internal/infrastructure/streams/producer.go` + +```go +func NewProducer(redisURL string) (*Producer, error) +func (p *Producer) Publish(ctx context.Context, stream string, event any) error +func (p *Producer) Close() error +``` + +`Publish` marshals `event` to JSON and appends it to the named stream via `XADD` with +auto-generated IDs (`*`). The JSON is stored in a single `"data"` field: + +```go +p.client.XAdd(ctx, &redis.XAddArgs{ + Stream: stream, + Values: map[string]any{"data": string(payload)}, +}) +``` + +Call `producer.Close()` during application shutdown to release the Redis connection. + +### Example — publishing from a use case + +```go +producer, err := streams.NewProducer(redisURL) +// ... +err = producer.Publish(ctx, streams.StreamUserCreated, streams.UserCreatedEvent{ + UserID: user.ID, + Email: user.Email, +}) +``` + +## Consuming events + +`internal/infrastructure/streams/consumer.go` + +```go +func NewConsumer(redisURL, stream, group, consumer string) (*Consumer, error) +func (c *Consumer) Run(ctx context.Context, h Handler) error // blocking; cancel ctx to stop +func (c *Consumer) Close() error + +type Handler func(ctx context.Context, data []byte) error +``` + +`NewConsumer` takes four arguments: the Redis URL, the stream name constant, a consumer +group name, and a unique consumer name within the group. + +### Run behaviour + +`Run` blocks until `ctx` is cancelled. On each iteration it: + +1. Calls `XGroupCreateMkStream` once at startup — creates the consumer group and the + stream itself if either does not exist (`MKSTREAM`). +2. Issues `XReadGroup` with `">"` to fetch only new (undelivered) messages, blocking up + to 2000 ms per call. +3. For each message, calls the `Handler` with the raw JSON bytes from the `"data"` field. +4. On handler success: acknowledges the message with `XACK`. +5. On handler error: logs via `slog.Error` and continues — the message is not + acknowledged and will be redelivered on next startup (pending entries). +6. On `ctx` cancellation: returns `nil` cleanly. +7. On `redis.Nil` (timeout with no messages): continues the loop. +8. On other Redis errors: logs and continues. + +### Example — registering a consumer goroutine in main.go + +```go +consumer, err := streams.NewConsumer(app.Config.RedisURL, + streams.StreamUserCreated, "api-group", "api-consumer-1") +if err != nil { + // handle +} +go func() { + if err := consumer.Run(ctx, handleUserCreated); err != nil { + slog.Error("streams: consumer error", "err", err) + } +}() +``` + +Cancel `ctx` (the same child context used for the worker) to stop the consumer during +shutdown, then call `consumer.Close()` to release the connection. + +## Adding a new event type + +1. Add a `Stream = "stream:."` constant to + `internal/infrastructure/streams/events.go`. +2. Add a `Event` payload struct with JSON tags in the same file. +3. Call `producer.Publish(ctx, streams., Event{...})` from + the relevant domain action. +4. Register a `streams.NewConsumer` goroutine in `cmd/api/main.go` (or the consuming + service's entry point), passing a `Handler` func that processes the raw JSON bytes. + +## Testing + +Integration tests use a Testcontainers Redis instance following the same `TestMain` +pattern as `internal/infrastructure/cache/redis/cache_test.go`. + +Typical test flow: + +```go +producer, _ := streams.NewProducer(redisURL) +producer.Publish(ctx, streams.StreamUserCreated, streams.UserCreatedEvent{ + UserID: "u1", Email: "a@b.com", +}) +producer.Close() + +// Verify the message was appended +msgs, _ := redisClient.XRange(ctx, streams.StreamUserCreated, "-", "+").Result() +// assert len(msgs) == 1 and msgs[0].Values["data"] contains expected JSON +``` + +Consumer handler logic is tested by invoking the `Handler` func directly with a +pre-marshalled `[]byte` payload — no Redis required for unit tests. diff --git a/backend/docs/swagger/docs.go b/backend/docs/swagger/docs.go index 9a74018..7d4855d 100644 --- a/backend/docs/swagger/docs.go +++ b/backend/docs/swagger/docs.go @@ -37,6 +37,25 @@ const docTemplate = `{ } } }, + "/admin/queues": { + "get": { + "produces": [ + "text/html" + ], + "tags": [ + "observability" + ], + "summary": "Asynq job monitoring UI", + "responses": { + "200": { + "description": "Asynqmon UI", + "schema": { + "type": "string" + } + } + } + } + }, "/api/v1/me": { "get": { "security": [ diff --git a/backend/docs/swagger/swagger.json b/backend/docs/swagger/swagger.json index 40a1319..89156fd 100644 --- a/backend/docs/swagger/swagger.json +++ b/backend/docs/swagger/swagger.json @@ -31,6 +31,25 @@ } } }, + "/admin/queues": { + "get": { + "produces": [ + "text/html" + ], + "tags": [ + "observability" + ], + "summary": "Asynq job monitoring UI", + "responses": { + "200": { + "description": "Asynqmon UI", + "schema": { + "type": "string" + } + } + } + } + }, "/api/v1/me": { "get": { "security": [ diff --git a/backend/docs/swagger/swagger.yaml b/backend/docs/swagger/swagger.yaml index 5789ec5..c744dc8 100644 --- a/backend/docs/swagger/swagger.yaml +++ b/backend/docs/swagger/swagger.yaml @@ -58,6 +58,18 @@ paths: summary: Hello World tags: - general + /admin/queues: + get: + produces: + - text/html + responses: + "200": + description: Asynqmon UI + schema: + type: string + summary: Asynq job monitoring UI + tags: + - observability /api/v1/me: get: description: 'Returns the authenticated Firebase user''s decoded claims. Requires diff --git a/backend/go.mod b/backend/go.mod index 5bad526..3cfa6fa 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -13,6 +13,8 @@ require ( github.com/gin-contrib/cors v1.7.7 github.com/gin-gonic/gin v1.12.0 github.com/gorilla/websocket v1.5.3 + github.com/hibiken/asynq v0.26.0 + github.com/hibiken/asynqmon v0.7.2 github.com/jackc/pgx/v5 v5.10.0 github.com/joho/godotenv v1.5.1 github.com/pressly/goose/v3 v3.27.1 @@ -104,6 +106,7 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.16 // indirect github.com/googleapis/gax-go/v2 v2.22.0 // indirect + github.com/gorilla/mux v1.8.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect @@ -141,9 +144,11 @@ require ( github.com/prometheus/procfs v0.20.1 // indirect github.com/quic-go/qpack v0.6.0 // indirect github.com/quic-go/quic-go v0.60.0 // indirect + github.com/robfig/cron/v3 v3.0.1 // indirect github.com/sethvargo/go-retry v0.3.0 // indirect github.com/shirou/gopsutil/v4 v4.26.3 // indirect github.com/sirupsen/logrus v1.9.4 // indirect + github.com/spf13/cast v1.10.0 // indirect github.com/spiffe/go-spiffe/v2 v2.6.0 // indirect github.com/stretchr/testify v1.11.1 // indirect github.com/tklauser/go-sysconf v0.3.16 // indirect diff --git a/backend/go.sum b/backend/go.sum index 43058d2..924372e 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -1,5 +1,7 @@ cel.dev/expr v0.25.2 h1:K6j46C81hXtZQfuX60cVWQFBJahKSE2gfRbNuvr5bFs= cel.dev/expr v0.25.2/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.123.0 h1:2NAUJwPR47q+E35uaJeYoNhuNEM9kM8SjgRgdeOJUSE= cloud.google.com/go v0.123.0/go.mod h1:xBoMV08QcqUGuPW65Qfm1o9Y4zKZBpGS+7bImXLTAZU= cloud.google.com/go/auth v0.20.0 h1:kXTssoVb4azsVDoUiF8KvxAqrsQcQtB53DcSgta74CA= @@ -30,6 +32,7 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8af github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg= github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.32.0 h1:rIkQfkCOVKc1OiRCNcSDD8ml5RJlZbH/Xsq7lbpynwc= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.32.0/go.mod h1:RD2SsorTmYhF6HkTmDw7KmPYQk8OBYwTkuasChwv7R4= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.56.0 h1:O2sXMyJh8b7devAGdE+163xtRurt0RVpB6DIzX5vGfg= @@ -48,6 +51,11 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/aws/aws-sdk-go-v2 v1.42.0 h1:XvXMJTkFQtpBKIWZnmr9ZEOc2InWM2yldjXEJ/bymhA= github.com/aws/aws-sdk-go-v2 v1.42.0/go.mod h1:27+ACypSLljLAEKsCYOmrjKh83vuTRkuAe9Uv/3A4bg= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.13 h1:p1BBrg/Hhp6uK7zpejeI8QFXHJeC/mynzi04Sl03k9g= @@ -84,10 +92,14 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.43.3 h1:VrIhKRCSK1umelSgB9RghvA9RTUY github.com/aws/aws-sdk-go-v2/service/sts v1.43.3/go.mod h1:r8wkDOuLaaMFqFiYAb8dGY2A3gJCOujMc6CFOVC4Zhc= github.com/aws/smithy-go v1.27.1 h1:4T340VFndXtADGF52gYa1POyL7s9E4Z1OeZ1hCscIw8= github.com/aws/smithy-go v1.27.1/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= +github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/bytedance/gopkg v0.1.4 h1:oZnQwnX82KAIWb7033bEwtxvTqXcYMxDBaQxo5JJHWM= @@ -98,8 +110,13 @@ github.com/bytedance/sonic/loader v0.5.1 h1:Ygpfa9zwRCCKSlrp5bBP/b/Xzc3VxsAW+5NI github.com/bytedance/sonic/loader v0.5.1/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudwego/base64x v0.1.7 h1:NppS+Fgzg5ovhn4NkUXaDT3x9jldgH5ToMCqzBSi2zI= github.com/cloudwego/base64x v0.1.7/go.mod h1:Cu1PV9zfrSf7ET2tIbWbbEy7jO7HHJ13q4X2SQ8aWYg= github.com/cncf/xds/go v0.0.0-20260202195803-dba9d589def2 h1:aBangftG7EVZoUb69Os8IaYg++6uMOdKK83QtkkvJik= @@ -121,6 +138,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/go-connections v0.7.0 h1:6SsRfJddP22WMrCkj19x9WKjEDTB+ahsdiGYf0mN39c= @@ -131,16 +149,23 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/ebitengine/purego v0.10.0 h1:QIw4xfpWT6GWTzaW5XEKy3HXoqrJGx1ijYHzTF0/ISU= github.com/ebitengine/purego v0.10.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.14.0 h1:hbG2kr4RuFj222B6+7T83thSPqLjwBIfQawTkC++2HA= github.com/envoyproxy/go-control-plane v0.14.0/go.mod h1:NcS5X47pLl/hfqxU70yPwL9ZMkUlwlKxtAohpi2wBEU= github.com/envoyproxy/go-control-plane/envoy v1.37.0 h1:u3riX6BoYRfF4Dr7dwSOroNfdSbEPe9Yyl09/B6wBrQ= github.com/envoyproxy/go-control-plane/envoy v1.37.0/go.mod h1:DReE9MMrmecPy+YvQOAOHNYMALuowAnbjjEMkkWOi6A= github.com/envoyproxy/go-control-plane/ratelimit v0.1.0 h1:/G9QYbddjL25KvtKTv3an9lx6VBE2cnb8wp1vEGNYGI= github.com/envoyproxy/go-control-plane/ratelimit v0.1.0/go.mod h1:Wk+tMFAFbCXaJPzVVHnPgRKdUdwW/KdbRt94AzgRee4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v1.3.3 h1:MVQghNeW+LZcmXe7SY1V36Z+WFMDjpqGAGacLe2T0ds= github.com/envoyproxy/protoc-gen-validate v1.3.3/go.mod h1:TsndJ/ngyIdQRhMcVVGDDHINPLWB7C82oDArY51KfB0= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM= github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= github.com/getsentry/sentry-go v0.46.2 h1:1jhYwrKGa3sIpo/y5iDNXS5wDoT7I1KNzMHrnK6ojns= @@ -159,6 +184,12 @@ github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxI github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-jose/go-jose/v4 v4.1.4 h1:moDMcTHmvE6Groj34emNPLs/qtYXRVcd6S7NHbHz3kA= github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -184,18 +215,45 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.30.3 h1:4MU6YkEwx7GbcPJOZxrtbu+QfF3pJLJuaYTeAH0DYy8= github.com/go-playground/validator/v10 v10.30.3/go.mod h1:4Axh7oCNGcoGkqLoE4YWt6n20mcEIsPRlB7vPk3lpyc= +github.com/go-redis/redis/v8 v8.11.2/go.mod h1:DLomh7y2e3ggQXQLd1YgmvIfecPJoFl7WU5SOQ/r06M= +github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU= github.com/goccy/go-json v0.10.6/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM= github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI= github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -203,14 +261,26 @@ github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9 github.com/google/martian/v3 v3.3.3/go.mod h1:iEPrYcgCF7jA9OtScMFQyAlZZ4YXTKEtJ1E6RWzmBA0= github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0= github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.3.16 h1:F/VPrx0YPBdksZJQdCAp0WUsqnNmZpUZszzfYt0M5Dw= github.com/googleapis/enterprise-certificate-proxy v0.3.16/go.mod h1:9Yb0eAkH/Xqhvv3zbeKf/+wMJqCeocWc6KIhDvEAuYE= github.com/googleapis/gax-go/v2 v2.22.0 h1:PjIWBpgGIVKGoCXuiCoP64altEJCj3/Ei+kSU5vlZD4= github.com/googleapis/gax-go/v2 v2.22.0/go.mod h1:irWBbALSr0Sk3qlqb9SyJ1h68WjgeFuiOzI4Rqw5+aY= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hibiken/asynq v0.19.0/go.mod h1:tyc63ojaW8SJ5SBm8mvI4DDONsguP5HE85EEl4Qr5Ig= +github.com/hibiken/asynq v0.24.1/go.mod h1:u5qVeSbrnfT+vtG5Mq8ZPzQu/BmCKMHvTGb91uy9Tts= +github.com/hibiken/asynq v0.26.0 h1:1Zxr92MlDnb1Zt/QR5g2vSCqUS03i95lUfqx5X7/wrw= +github.com/hibiken/asynq v0.26.0/go.mod h1:Qk4e57bTnWDoyJ67VkchuV6VzSM9IQW2nPvAGuDyw58= +github.com/hibiken/asynq/x v0.0.0-20211219150637-8dfabfccb3be/go.mod h1:VmxwMfMKyb6gyv8xG0oOBMXIhquWKPx+zPtbVBd2Q1s= +github.com/hibiken/asynqmon v0.7.2 h1:YohWgTIPwtMyZ6khBDcVUz9BdSdQW2Dxn8SoxtbmjSg= +github.com/hibiken/asynqmon v0.7.2/go.mod h1:jUbrpFNDwoJ6avGNjHIazFuCmQj78C3dbJowV0x9x8E= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= @@ -223,13 +293,23 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/klauspost/compress v1.18.5 h1:/h1gH5Ce+VWNLSWqPzOVn6XBO+vJbCNGvjoaGBFW2IE= github.com/klauspost/compress v1.18.5/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -252,6 +332,7 @@ github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4= github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mdelapenya/tlscert v0.2.0 h1:7H81W6Z/4weDvZBNOfQte5GpIMo0lGYEeWbkGp5LJHI= github.com/mdelapenya/tlscert v0.2.0/go.mod h1:O4njj3ELLnJjGdkN7M/vIVCpZ+Cf0L6muqOG4tLSl8o= github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY= @@ -277,13 +358,27 @@ github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFL github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= +github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= @@ -292,6 +387,8 @@ github.com/pelletier/go-toml/v2 v2.3.1 h1:MYEvvGnQjeNkRF1qUuGolNtNExTDwct51yp7ol github.com/pelletier/go-toml/v2 v2.3.1/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= @@ -303,12 +400,28 @@ github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/pressly/goose/v3 v3.27.1 h1:6uEvcprBybDmW4hcz3gYujhARhye+GoWKhEWyzD5sh4= github.com/pressly/goose/v3 v3.27.1/go.mod h1:maruOxsPnIG2yHHyo8UqKWXYKFcH7Q76csUV7+7KYoM= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs= github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc= github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo= github.com/quic-go/go-ossfuzz-seeds v0.1.0 h1:APacT+iIaNF6fd8AGEiN3bT/Jtkd2jz4v4TzM7MFjy0= @@ -317,27 +430,44 @@ github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8= github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII= github.com/quic-go/quic-go v0.60.0 h1:xcQioE8OM66UQLeUMHltK1CCcOu3JbVB4JAQdDQSB+0= github.com/quic-go/quic-go v0.60.0/go.mod h1:wpKpjmPpftl30sL6pFh7REVpjbcCVy4zt2vDyK1TuJk= +github.com/redis/go-redis/v9 v9.0.3/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= +github.com/redis/go-redis/v9 v9.0.4/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= github.com/redis/go-redis/v9 v9.20.1 h1:sfCU6A8P3dXbKyWes02uxA2baehGux9dZHfEKtsTB1w= github.com/redis/go-redis/v9 v9.20.1/go.mod h1:v/M13XI1PVCDcm01VtPFOADfZtHf8YW3baQf57KlIkA= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE= github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas= github.com/shirou/gopsutil/v4 v4.26.3 h1:2ESdQt90yU3oXF/CdOlRCJxrP+Am1aBYubTMTfxJ1qc= github.com/shirou/gopsutil/v4 v4.26.3/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w= github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= +github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= github.com/spiffe/go-spiffe/v2 v2.6.0 h1:l+DolpxNWYgruGQVV0xsfeya3CsC7m8iBzDnMpsbLuo= github.com/spiffe/go-spiffe/v2 v2.6.0/go.mod h1:gm2SeUoMZEtpnzPNs2Csc0D/gX33k1xIx7lEzqblHEs= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -364,6 +494,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY= github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= @@ -393,6 +525,8 @@ go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09 go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/goleak v0.10.0/go.mod h1:VCZuO8V8mFPlL0F5J5GK1rtHV3DrFcQ1R8ryq7FK0aI= +go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= @@ -403,36 +537,92 @@ go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI= go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU= golang.org/x/arch v0.28.0 h1:wVwVdqsTuUbJvhYVCspQYwZXHNYeLSoZnmHD+ggddpQ= golang.org/x/arch v0.28.0/go.mod h1:0X+GdSIP+kL5wPmpK7sdkEVTt2XoYP0cSjQSbZBwOi8= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto= golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.36.0 h1:JJjpVx6myfUsUdAzZuOSTTmRE0PfZeNWzzvKrP7amb4= golang.org/x/mod v0.36.0/go.mod h1:moc6ELqsWcOw5Ef3xVprK5ul/MvtVvkIXLziUOICjUQ= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o= golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -441,6 +631,7 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc= golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -448,39 +639,76 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE= golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.45.0 h1:18qN3FAooORvApf5XjCXgsuayZOEtXf6JK18I3+ONa8= golang.org/x/tools v0.45.0/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= google.golang.org/api v0.284.0 h1:i+cKTgeQRcRySkP7QTl5PDO7/pAm8EcMFIUMlNbk4Vc= google.golang.org/api v0.284.0/go.mod h1:AU44fU+XVZOCcd8uLaBIa/ZgzgPf/0qqY3+m7lQaado= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine/v2 v2.0.6 h1:LvPZLGuchSBslPBp+LAhihBeGSiRh1myRoYK4NtuBIw= google.golang.org/appengine/v2 v2.0.6/go.mod h1:WoEXGoXNfa0mLvaH5sV3ZSGXwVmy8yf7Z1JKf3J3wLI= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20260511170946-3700d4141b60 h1:rhBdfmsOlOZIvz3Y5/BdUzPg2CkO8L7QQPKj96B8554= google.golang.org/genproto v0.0.0-20260511170946-3700d4141b60/go.mod h1:8xo2Pj1b20ZOCpzlU3B9qieMwVIAXx1QVZWLMlPL6sM= google.golang.org/genproto/googleapis/api v0.0.0-20260511170946-3700d4141b60 h1:3WsB1FAbiRIf2tOxscWKs3pQBD9he1NsrnbhMuWfekc= google.golang.org/genproto/googleapis/api v0.0.0-20260511170946-3700d4141b60/go.mod h1:7yoXV7RIh5gblj/xVYoogxAWvA9wUeVbpsK/M694l00= google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa h1:mZHHdPZl0dbGHCflZgAq/Q468DWVFcU2whhB2KAo8fk= google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.81.1 h1:VnnIIZ88UzOOKLukQi+ImGz8O1Wdp8nAGGnvOfEIWQQ= google.golang.org/grpc v1.81.1/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -489,6 +717,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= modernc.org/libc v1.72.1 h1:db1xwJ6u1kE3KHTFTTbe2GCrczHPKzlURP0aDC4NGD0= modernc.org/libc v1.72.1/go.mod h1:HRMiC/PhPGLIPM7GzAFCbI+oSgE3dhZ8FWftmRrHVlY= modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= diff --git a/backend/internal/bootstrap/bootstrap.go b/backend/internal/bootstrap/bootstrap.go index 5e55f99..3d4eb2f 100644 --- a/backend/internal/bootstrap/bootstrap.go +++ b/backend/internal/bootstrap/bootstrap.go @@ -17,6 +17,7 @@ import ( "backend/internal/infrastructure/cache/redis" "backend/internal/infrastructure/database/postgres" + "backend/internal/infrastructure/queue" "backend/internal/usecase" "backend/pkg/firebase" "backend/pkg/logger" @@ -35,6 +36,7 @@ const ( type App struct { DB *sql.DB Cache usecase.CacheService // nil when REDIS_URL is not set + Enqueuer usecase.Enqueuer // nil when REDIS_URL is not set Firebase usecase.FirebaseAdminClient // nil when FIREBASE_PROJECT_ID is not set Config Config Log *slog.Logger @@ -106,6 +108,15 @@ func Run(ctx context.Context) (*App, error) { cache = c } + var enqueuer usecase.Enqueuer + if cfg.RedisURL != "" { + eq, err := queue.NewClient(cfg.RedisURL) + if err != nil { + return nil, fmt.Errorf("bootstrap: queue: %w", err) + } + enqueuer = eq + } + var firebaseClient usecase.FirebaseAdminClient if cfg.FirebaseProjectID != "" { client, err := firebase.NewAuthClient(ctx, cfg.FirebaseProjectID, cfg.FirebaseServiceAccountJSON) @@ -121,6 +132,7 @@ func Run(ctx context.Context) (*App, error) { return &App{ DB: db, Cache: cache, + Enqueuer: enqueuer, Firebase: firebaseClient, Config: cfg, Log: log, diff --git a/backend/internal/infrastructure/queue/client.go b/backend/internal/infrastructure/queue/client.go new file mode 100644 index 0000000..9318ab2 --- /dev/null +++ b/backend/internal/infrastructure/queue/client.go @@ -0,0 +1,42 @@ +package queue + +import ( + "context" + "fmt" + + "github.com/hibiken/asynq" + goredis "github.com/redis/go-redis/v9" + + "backend/internal/usecase" +) + +type client struct { + asynq *asynq.Client +} + +// NewClient creates a usecase.Enqueuer backed by Asynq. +// redisURL must be a valid redis:// URI (same value as REDIS_URL). +func NewClient(redisURL string) (usecase.Enqueuer, error) { + opt, err := goredis.ParseURL(redisURL) + if err != nil { + return nil, fmt.Errorf("queue: parse redis url: %w", err) + } + c := asynq.NewClient(asynq.RedisClientOpt{ + Addr: opt.Addr, + Password: opt.Password, + DB: opt.DB, + }) + return &client{asynq: c}, nil +} + +// Enqueue submits a task of the given type with the provided payload. +func (c *client) Enqueue(ctx context.Context, taskType string, payload []byte) error { + task := asynq.NewTask(taskType, payload) + _, err := c.asynq.EnqueueContext(ctx, task) + return err +} + +// Close releases the underlying Asynq client connection. +func (c *client) Close() error { + return c.asynq.Close() +} diff --git a/backend/internal/infrastructure/queue/client_test.go b/backend/internal/infrastructure/queue/client_test.go new file mode 100644 index 0000000..a23cae0 --- /dev/null +++ b/backend/internal/infrastructure/queue/client_test.go @@ -0,0 +1,74 @@ +package queue + +import ( + "context" + "encoding/json" + "fmt" + "log" + "os" + "testing" + + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" + + "backend/internal/usecase" +) + +var testEnqueuer usecase.Enqueuer + +func mustStartRedisContainerForQueue() (func(context.Context, ...testcontainers.TerminateOption) error, error) { + ctx := context.Background() + container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ + ContainerRequest: testcontainers.ContainerRequest{ + Image: "redis:7-alpine", + ExposedPorts: []string{"6379/tcp"}, + WaitingFor: wait.ForLog("Ready to accept connections"), + }, + Started: true, + }) + if err != nil { + return nil, fmt.Errorf("start redis container: %w", err) + } + host, err := container.Host(ctx) + if err != nil { + return container.Terminate, fmt.Errorf("container host: %w", err) + } + port, err := container.MappedPort(ctx, "6379/tcp") + if err != nil { + return container.Terminate, fmt.Errorf("mapped port: %w", err) + } + redisURL := fmt.Sprintf("redis://%s:%s", host, port.Port()) + eq, err := NewClient(redisURL) + if err != nil { + return container.Terminate, fmt.Errorf("new queue client: %w", err) + } + testEnqueuer = eq + return container.Terminate, nil +} + +func TestMain(m *testing.M) { + teardown, err := mustStartRedisContainerForQueue() + if err != nil { + // Docker unavailable — skip integration tests but let unit tests in this + // package run (handlers_test.go has no container dependency). + log.Printf("queue integration tests skipped: %v", err) + } + code := m.Run() + if teardown != nil { + if err := teardown(context.Background()); err != nil { + log.Printf("teardown redis container: %v", err) + } + } + os.Exit(code) +} + +func TestEnqueue_WelcomeEmail(t *testing.T) { + if testEnqueuer == nil { + t.Skip("requires Docker") + } + payload, _ := json.Marshal(WelcomeEmailPayload{UserID: "u1", Email: "test@example.com"}) + err := testEnqueuer.Enqueue(context.Background(), TypeWelcomeEmail, payload) + if err != nil { + t.Errorf("Enqueue() returned unexpected error: %v", err) + } +} diff --git a/backend/internal/infrastructure/queue/handlers.go b/backend/internal/infrastructure/queue/handlers.go new file mode 100644 index 0000000..700da67 --- /dev/null +++ b/backend/internal/infrastructure/queue/handlers.go @@ -0,0 +1,21 @@ +package queue + +import ( + "context" + "encoding/json" + "fmt" + "log/slog" + + "github.com/hibiken/asynq" +) + +// HandleWelcomeEmail logs the welcome email payload. +// Real delivery via Mailjet is wired in issue #20. +func HandleWelcomeEmail(_ context.Context, t *asynq.Task) error { + var p WelcomeEmailPayload + if err := json.Unmarshal(t.Payload(), &p); err != nil { + return fmt.Errorf("welcome email: unmarshal payload: %w", err) + } + slog.Info("queue: welcome email task received", "user_id", p.UserID, "email", p.Email) + return nil +} diff --git a/backend/internal/infrastructure/queue/handlers_test.go b/backend/internal/infrastructure/queue/handlers_test.go new file mode 100644 index 0000000..183966f --- /dev/null +++ b/backend/internal/infrastructure/queue/handlers_test.go @@ -0,0 +1,29 @@ +package queue_test + +import ( + "context" + "encoding/json" + "testing" + + "github.com/hibiken/asynq" + + "backend/internal/infrastructure/queue" +) + +func TestHandleWelcomeEmail_ValidPayload(t *testing.T) { + payload, err := json.Marshal(queue.WelcomeEmailPayload{UserID: "u1", Email: "test@example.com"}) + if err != nil { + t.Fatalf("marshal: %v", err) + } + task := asynq.NewTask(queue.TypeWelcomeEmail, payload) + if err := queue.HandleWelcomeEmail(context.Background(), task); err != nil { + t.Errorf("unexpected error: %v", err) + } +} + +func TestHandleWelcomeEmail_InvalidPayload(t *testing.T) { + task := asynq.NewTask(queue.TypeWelcomeEmail, []byte("not-json")) + if err := queue.HandleWelcomeEmail(context.Background(), task); err == nil { + t.Error("expected error for invalid payload, got nil") + } +} diff --git a/backend/internal/infrastructure/queue/tasks.go b/backend/internal/infrastructure/queue/tasks.go new file mode 100644 index 0000000..62008a4 --- /dev/null +++ b/backend/internal/infrastructure/queue/tasks.go @@ -0,0 +1,13 @@ +package queue + +// Task type constants used by both enqueuers and handlers. +const ( + TypeWelcomeEmail = "email:welcome" +) + +// WelcomeEmailPayload is the JSON payload for TypeWelcomeEmail tasks. +// Real delivery via Mailjet is wired in issue #20. +type WelcomeEmailPayload struct { + UserID string `json:"user_id"` + Email string `json:"email"` +} diff --git a/backend/internal/infrastructure/queue/worker.go b/backend/internal/infrastructure/queue/worker.go new file mode 100644 index 0000000..f47e1df --- /dev/null +++ b/backend/internal/infrastructure/queue/worker.go @@ -0,0 +1,67 @@ +package queue + +import ( + "context" + "fmt" + "log/slog" + + "github.com/hibiken/asynq" + goredis "github.com/redis/go-redis/v9" +) + +// Worker wraps an asynq.Server and routes tasks to registered handlers. +type Worker struct { + server *asynq.Server + mux *asynq.ServeMux +} + +// NewWorker creates a Worker using the given Redis URL. +func NewWorker(redisURL string) (*Worker, error) { + opt, err := goredis.ParseURL(redisURL) + if err != nil { + return nil, fmt.Errorf("queue: parse redis url: %w", err) + } + srv := asynq.NewServer( + asynq.RedisClientOpt{Addr: opt.Addr, Password: opt.Password, DB: opt.DB}, + asynq.Config{ + Concurrency: 10, + ErrorHandler: asynq.ErrorHandlerFunc(func(_ context.Context, t *asynq.Task, err error) { + slog.Error("queue: task failed", "type", t.Type(), "err", err) + }), + }, + ) + return &Worker{server: srv, mux: asynq.NewServeMux()}, nil +} + +// Register adds a handler for the given task type. +func (w *Worker) Register(taskType string, h asynq.Handler) { + w.mux.Handle(taskType, h) +} + +// Run starts processing until ctx is cancelled. +// Call this in its own goroutine — it blocks. +func (w *Worker) Run(ctx context.Context) error { + errCh := make(chan error, 1) + go func() { + if err := w.server.Run(w.mux); err != nil { + errCh <- err + } + }() + select { + case <-ctx.Done(): + w.server.Shutdown() + return nil + case err := <-errCh: + return err + } +} + +// NewInspector returns a low-level asynq.Inspector for the same Redis instance. +// Used by Asynqmon to read queue state. +func NewInspector(redisURL string) (*asynq.Inspector, error) { + opt, err := goredis.ParseURL(redisURL) + if err != nil { + return nil, fmt.Errorf("queue: parse redis url: %w", err) + } + return asynq.NewInspector(asynq.RedisClientOpt{Addr: opt.Addr, Password: opt.Password, DB: opt.DB}), nil +} diff --git a/backend/internal/infrastructure/streams/consumer.go b/backend/internal/infrastructure/streams/consumer.go new file mode 100644 index 0000000..be65421 --- /dev/null +++ b/backend/internal/infrastructure/streams/consumer.go @@ -0,0 +1,76 @@ +package streams + +import ( + "context" + "fmt" + "log/slog" + + "github.com/redis/go-redis/v9" +) + +// Handler processes a single stream message payload (raw JSON bytes). +type Handler func(ctx context.Context, data []byte) error + +// Consumer reads from a Redis Stream via a consumer group. +type Consumer struct { + client *redis.Client + stream string + group string + consumer string +} + +// NewConsumer creates a Consumer for the given stream / group / consumer name. +func NewConsumer(redisURL, stream, group, consumer string) (*Consumer, error) { + opts, err := redis.ParseURL(redisURL) + if err != nil { + return nil, fmt.Errorf("streams: parse redis url: %w", err) + } + return &Consumer{ + client: redis.NewClient(opts), + stream: stream, + group: group, + consumer: consumer, + }, nil +} + +// Run reads and dispatches messages until ctx is cancelled. +// Creates the consumer group (and stream) if either does not exist. +func (c *Consumer) Run(ctx context.Context, h Handler) error { + // MKSTREAM ensures the stream exists before the first publish. + _ = c.client.XGroupCreateMkStream(ctx, c.stream, c.group, "0").Err() + + for { + entries, err := c.client.XReadGroup(ctx, &redis.XReadGroupArgs{ + Group: c.group, + Consumer: c.consumer, + Streams: []string{c.stream, ">"}, + Count: 10, + Block: 2000, + }).Result() + if err != nil { + if ctx.Err() != nil { + return nil + } + if err == redis.Nil { + continue + } + slog.Error("streams: read error", "stream", c.stream, "err", err) + continue + } + for _, entry := range entries { + for _, msg := range entry.Messages { + data, _ := msg.Values["data"].(string) + if err := h(ctx, []byte(data)); err != nil { + slog.Error("streams: handler error", "msg_id", msg.ID, "err", err) + } else { + _ = c.client.XAck(ctx, c.stream, c.group, msg.ID) + } + } + } + } +} + +// Close releases the underlying Redis connection. +func (c *Consumer) Close() error { + return c.client.Close() +} diff --git a/backend/internal/infrastructure/streams/events.go b/backend/internal/infrastructure/streams/events.go new file mode 100644 index 0000000..d2411ec --- /dev/null +++ b/backend/internal/infrastructure/streams/events.go @@ -0,0 +1,13 @@ +package streams + +// Stream name constants for Redis Streams event log. +const ( + StreamUserCreated = "stream:user.created" + StreamNotificationSent = "stream:notification.sent" +) + +// UserCreatedEvent is published when a new user account is created. +type UserCreatedEvent struct { + UserID string `json:"user_id"` + Email string `json:"email"` +} diff --git a/backend/internal/infrastructure/streams/producer.go b/backend/internal/infrastructure/streams/producer.go new file mode 100644 index 0000000..3799196 --- /dev/null +++ b/backend/internal/infrastructure/streams/producer.go @@ -0,0 +1,40 @@ +package streams + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/redis/go-redis/v9" +) + +// Producer appends events to Redis Streams. +type Producer struct { + client *redis.Client +} + +// NewProducer creates a Producer for the given Redis URL. +func NewProducer(redisURL string) (*Producer, error) { + opts, err := redis.ParseURL(redisURL) + if err != nil { + return nil, fmt.Errorf("streams: parse redis url: %w", err) + } + return &Producer{client: redis.NewClient(opts)}, nil +} + +// Publish appends event to the named stream as a JSON "data" field. +func (p *Producer) Publish(ctx context.Context, stream string, event any) error { + payload, err := json.Marshal(event) + if err != nil { + return fmt.Errorf("streams: marshal event: %w", err) + } + return p.client.XAdd(ctx, &redis.XAddArgs{ + Stream: stream, + Values: map[string]any{"data": string(payload)}, + }).Err() +} + +// Close releases the underlying Redis connection. +func (p *Producer) Close() error { + return p.client.Close() +} diff --git a/backend/internal/infrastructure/streams/producer_test.go b/backend/internal/infrastructure/streams/producer_test.go new file mode 100644 index 0000000..104f0cf --- /dev/null +++ b/backend/internal/infrastructure/streams/producer_test.go @@ -0,0 +1,93 @@ +package streams + +import ( + "context" + "encoding/json" + "fmt" + "log" + "testing" + + goredis "github.com/redis/go-redis/v9" + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" +) + +var testRedisURL string + +func mustStartRedisContainerForStreams() (func(context.Context, ...testcontainers.TerminateOption) error, error) { + ctx := context.Background() + container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ + ContainerRequest: testcontainers.ContainerRequest{ + Image: "redis:7-alpine", + ExposedPorts: []string{"6379/tcp"}, + WaitingFor: wait.ForLog("Ready to accept connections"), + }, + Started: true, + }) + if err != nil { + return nil, fmt.Errorf("start redis container: %w", err) + } + host, err := container.Host(ctx) + if err != nil { + return container.Terminate, fmt.Errorf("container host: %w", err) + } + port, err := container.MappedPort(ctx, "6379/tcp") + if err != nil { + return container.Terminate, fmt.Errorf("mapped port: %w", err) + } + testRedisURL = fmt.Sprintf("redis://%s:%s", host, port.Port()) + return container.Terminate, nil +} + +func TestMain(m *testing.M) { + teardown, err := mustStartRedisContainerForStreams() + if err != nil { + log.Fatalf("could not start redis container: %v", err) + } + m.Run() + if teardown != nil { + if err := teardown(context.Background()); err != nil { + log.Fatalf("could not teardown redis container: %v", err) + } + } +} + +func TestProducer_Publish(t *testing.T) { + ctx := context.Background() + p, err := NewProducer(testRedisURL) + if err != nil { + t.Fatalf("NewProducer: %v", err) + } + defer p.Close() + + event := UserCreatedEvent{UserID: "u1", Email: "test@example.com"} + if err := p.Publish(ctx, StreamUserCreated, event); err != nil { + t.Fatalf("Publish: %v", err) + } + + // Read the message back directly to verify it was appended. + opts, _ := goredis.ParseURL(testRedisURL) + rc := goredis.NewClient(opts) + defer rc.Close() + + entries, err := rc.XRange(ctx, StreamUserCreated, "-", "+").Result() + if err != nil { + t.Fatalf("XRange: %v", err) + } + if len(entries) != 1 { + t.Fatalf("expected 1 stream entry, got %d", len(entries)) + } + + data, ok := entries[0].Values["data"].(string) + if !ok { + t.Fatal("stream entry missing 'data' field") + } + + var got UserCreatedEvent + if err := json.Unmarshal([]byte(data), &got); err != nil { + t.Fatalf("unmarshal: %v", err) + } + if got.UserID != event.UserID || got.Email != event.Email { + t.Errorf("got %+v, want %+v", got, event) + } +} diff --git a/backend/internal/server/server.go b/backend/internal/server/server.go index f619ddb..80a5dcf 100644 --- a/backend/internal/server/server.go +++ b/backend/internal/server/server.go @@ -7,7 +7,10 @@ import ( "time" "github.com/gin-gonic/gin" + "github.com/hibiken/asynq" + "github.com/hibiken/asynqmon" "github.com/prometheus/client_golang/prometheus" + goredis "github.com/redis/go-redis/v9" "backend/internal/bootstrap" "backend/internal/infrastructure/database/postgres" @@ -31,7 +34,24 @@ func NewServer(app *bootstrap.App, hub *ws.Hub) (*http.Server, error) { healthRepo := postgres.NewHealthRepository(app.DB) healthUC := usecase.NewHealthUseCase(healthRepo) - h := handlers.NewHandler(healthUC, app.Firebase, hub) + + // Build Asynqmon UI handler when Redis is available. + var queueUI http.Handler + if app.Config.RedisURL != "" { + redisOpt, err := goredis.ParseURL(app.Config.RedisURL) + if err == nil { + queueUI = asynqmon.New(asynqmon.Options{ + RootPath: "/admin/queues", + RedisConnOpt: asynq.RedisClientOpt{ + Addr: redisOpt.Addr, + Password: redisOpt.Password, + DB: redisOpt.DB, + }, + }) + } + } + + h := handlers.NewHandler(healthUC, app.Firebase, hub, app.Enqueuer, queueUI) // Register DB pool metrics collector. // AlreadyRegisteredError is silenced — only the first registration wins diff --git a/backend/internal/transport/handlers/handler.go b/backend/internal/transport/handlers/handler.go index 02f133c..de74329 100644 --- a/backend/internal/transport/handlers/handler.go +++ b/backend/internal/transport/handlers/handler.go @@ -1,6 +1,8 @@ package handlers import ( + "net/http" + "backend/internal/infrastructure/ws" "backend/internal/usecase" ) @@ -10,9 +12,23 @@ type Handler struct { healthUC usecase.HealthUseCase verifier usecase.FirebaseTokenVerifier // nil disables auth (dev only) hub *ws.Hub + enqueuer usecase.Enqueuer // nil when REDIS_URL is not set + queueUI http.Handler // nil disables /admin/queues route } // NewHandler constructs a Handler with all required use cases. -func NewHandler(healthUC usecase.HealthUseCase, verifier usecase.FirebaseTokenVerifier, hub *ws.Hub) *Handler { - return &Handler{healthUC: healthUC, verifier: verifier, hub: hub} +func NewHandler( + healthUC usecase.HealthUseCase, + verifier usecase.FirebaseTokenVerifier, + hub *ws.Hub, + enqueuer usecase.Enqueuer, + queueUI http.Handler, +) *Handler { + return &Handler{ + healthUC: healthUC, + verifier: verifier, + hub: hub, + enqueuer: enqueuer, + queueUI: queueUI, + } } diff --git a/backend/internal/transport/handlers/health_handler_test.go b/backend/internal/transport/handlers/health_handler_test.go index 566edbb..ec008a6 100644 --- a/backend/internal/transport/handlers/health_handler_test.go +++ b/backend/internal/transport/handlers/health_handler_test.go @@ -31,7 +31,7 @@ func TestHealthHandler_Success(t *testing.T) { Status: "up", Message: "It's healthy", } - h := NewHandler(&mockHealthUC{stats: want}, nil, nil) + h := NewHandler(&mockHealthUC{stats: want}, nil, nil, nil, nil) r := gin.New() r.GET("/health", h.HealthHandler) @@ -50,7 +50,7 @@ func TestHealthHandler_Success(t *testing.T) { } func TestHealthHandler_ServiceUnavailable(t *testing.T) { - h := NewHandler(&mockHealthUC{err: errors.New("connection refused")}, nil, nil) + h := NewHandler(&mockHealthUC{err: errors.New("connection refused")}, nil, nil, nil, nil) r := gin.New() r.GET("/health", h.HealthHandler) diff --git a/backend/internal/transport/handlers/queue_handler.go b/backend/internal/transport/handlers/queue_handler.go new file mode 100644 index 0000000..d2c1e1c --- /dev/null +++ b/backend/internal/transport/handlers/queue_handler.go @@ -0,0 +1,13 @@ +package handlers + +import "github.com/gin-gonic/gin" + +// QueueUIHandler serves the Asynqmon job monitoring UI. +// Only registered in debug mode when REDIS_URL is set. +// +// @Summary Asynq job monitoring UI +// @Tags observability +// @Produce html +// @Success 200 {string} string "Asynqmon UI" +// @Router /admin/queues [get] +func (h *Handler) QueueUIHandler(_ *gin.Context) {} diff --git a/backend/internal/transport/handlers/routes.go b/backend/internal/transport/handlers/routes.go index 7bf57c1..ab56763 100644 --- a/backend/internal/transport/handlers/routes.go +++ b/backend/internal/transport/handlers/routes.go @@ -53,6 +53,12 @@ func (h *Handler) RegisterRoutes(rps float64, burst int, sentryDSN string) http. r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) + // Asynqmon job-monitoring UI — debug/local only. + if gin.Mode() == gin.DebugMode && h.queueUI != nil { + r.GET("/admin/queues", gin.WrapH(h.queueUI)) + r.Any("/admin/queues/*path", gin.WrapH(h.queueUI)) + } + api := r.Group("/api/v1") if h.verifier != nil { api.Use(middleware.FirebaseAuth(h.verifier)) diff --git a/backend/internal/usecase/enqueuer.go b/backend/internal/usecase/enqueuer.go new file mode 100644 index 0000000..794e5fb --- /dev/null +++ b/backend/internal/usecase/enqueuer.go @@ -0,0 +1,11 @@ +package usecase + +import "context" + +// Enqueuer is the task-queue port that use cases depend on. +// The Asynq-backed implementation lives in internal/infrastructure/queue/. +// nil disables background job processing (when REDIS_URL is not set). +type Enqueuer interface { + Enqueue(ctx context.Context, taskType string, payload []byte) error + Close() error +}