From ab11eade6856f34d5e0d21386a18a96e8d0b17cd Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Thu, 5 Mar 2026 17:13:26 -0500 Subject: [PATCH] refactor: inject ConnectionManager into Worker Pass ConnectionManager to Worker constructor to enable WebSocket broadcasting capabilities. Updated: - main.go: server initialization - test_helpers.go: test setup - commonhandlers.go: handler initialization This change enables Worker to broadcast job updates to connected clients. --- cmd/server/main.go | 2 +- cmd/server/tests/test_helpers.go | 2 +- internal/handlers/commonhandlers.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index adac24a..c206f9a 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -105,7 +105,7 @@ func main() { libraryService := services.NewLibraryService(queries) // Create worker for background tasks - worker := services.NewWorker(3) + worker := services.NewWorker(3, connManager) services.WorkerInstance = worker koreaderHandler := handlers.NewKOReaderHandler(queries, connManager, queueProcessor) diff --git a/cmd/server/tests/test_helpers.go b/cmd/server/tests/test_helpers.go index a8caf0b..289b096 100644 --- a/cmd/server/tests/test_helpers.go +++ b/cmd/server/tests/test_helpers.go @@ -458,7 +458,7 @@ func setupTestServer(t *testing.T) *TestServerSetup { // Create refactored handlers (matching main.go) libraryService := services.NewLibraryService(queries) - worker := services.NewWorker(3) + worker := services.NewWorker(3, connManager) collectionHandler := handlers.NewCollectionHandler(queries, libraryService, connManager) dashboardService := services.NewDashboardService(queries) dashboardHandler := handlers.NewDashboardHandler(queries) diff --git a/internal/handlers/commonhandlers.go b/internal/handlers/commonhandlers.go index 50cd6b5..c773019 100644 --- a/internal/handlers/commonhandlers.go +++ b/internal/handlers/commonhandlers.go @@ -32,7 +32,7 @@ type Handler struct { func NewHandler(db *database.Queries, connManager *wsync.ConnectionManager, queueProcessor *wsync.SyncQueueProcessor, cfg *config.Config) *Handler { ctx, cancel := context.WithCancel(context.Background()) - worker := services.NewWorker(3) + worker := services.NewWorker(3, connManager) queueCtx, queueCancel := context.WithCancel(context.Background())