package main import ( "context" "net/http" "github.com/food-ai/backend/internal/domain/recognition" ) // App bundles the HTTP handler with background services that need lifecycle management. type App struct { handler http.Handler workerPool *recognition.WorkerPool sseBroker *recognition.SSEBroker } // ServeHTTP implements http.Handler. func (application *App) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request) { application.handler.ServeHTTP(responseWriter, request) } // Start launches the SSE broker's LISTEN loop and the worker pool goroutines. // Call this once before the HTTP server begins accepting connections. func (application *App) Start(applicationContext context.Context) { application.sseBroker.Start(applicationContext) application.workerPool.Start(applicationContext) }