feat(factory): add service state tracking, AwaitHealthy, depends_on, and /healthz#10671
Open
therealpandey wants to merge 15 commits intomainfrom
Open
feat(factory): add service state tracking, AwaitHealthy, depends_on, and /healthz#10671therealpandey wants to merge 15 commits intomainfrom
therealpandey wants to merge 15 commits intomainfrom
Conversation
…and /healthz endpoint Add explicit lifecycle state tracking to factory.Registry services (starting/running/failed) modeled after Guava's ServiceManager. Services can declare dependencies via NewNamedService(..., dependsOn) which are validated for unknown refs and cycles at registry creation. AwaitHealthy blocks until all services reach running state. A /healthz endpoint is wired through signozapiserver returning 200/503 with per-service state.
…les, fix test assertions Replace custom DFS cycle detection with gonum's topo.Sort + TarjanSCC. Dependency cycles now return an error from NewRegistry instead of being silently dropped. Use assert for final test assertions and require only for intermediate setup errors.
…ers struct Move Handler implementation to a private handler struct with NewHandler constructor instead of methods on *Registry. Route handler through the existing Handlers struct as RegistryHandler. Rename healthz.go to registry.go in signozapiserver. Fix handler_test.go for new param.
…, user depends on authz Add ServiceWithHealthy interface embedding Service + Healthy. NamedService now delegates Healthy() to the underlying service, eliminating unwrapService. AuthZ interface requires Healthy(), implemented in both pkg and ee providers. User service declares dependency on authz via dependsOn.
User service signals healthy after successful root user reconciliation or immediately when disabled. User Service interface now embeds factory.ServiceWithHealthy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
factory.Registryservices, modeled after Guava's ServiceManagerServiceWithHealthyinterface embeddingService+Healthy— services signal readiness via a channel, eliminating the need forunwrapServiceAwaitHealthy(ctx)method that blocks until all services reach running statedependsOnparameter toNewNamedServicefor declaring service dependencies with validation (unknown refs logged and dropped, self-deps ignored, cycles detected via gonum's Tarjan SCC and returned as errors)factory.Handlerinterface withHealthz,Readyz,Livezmethods, implemented viaNewHandler(registry)/api/v2/healthz,/api/v2/readyz,/api/v2/livezendpoints throughsignozapiserverreturning 200/503 with per-service stateServiceWithHealthyfor authz service (pkg + ee) — healthy after OpenFGA store/model setup completesServiceWithHealthyfor user service — healthy after root user reconciliation succeedsdependsOn/api/v2/healthzfor readiness checks with error-level logging on failuresTest plan
go test -race ./pkg/factory/...— 16 tests covering state transitions, AwaitHealthy, dependency ordering, failure propagation, self-dep/cycle detection, unknown dep handlinggo build ./...— full project builds cleango-lint— 0 issuesmake go-run-community→GET /api/v2/healthzreturns 200 with all services runningtest_setupasserts/api/v2/healthzreturns 200