feat: include Horizon reachability in readiness probe (issue #172) - #194
Merged
Manuel1234477 merged 2 commits intoJul 23, 2026
Merged
Conversation
…ateLabs#172) The /ready endpoint previously only checked the database. A deployment with Horizon unreachable still reported ready, causing the load balancer to route traffic to an instance that cannot detect on-chain payments. This change makes /ready check both the database AND Horizon before returning 200, and adds a dedicated /deps endpoint for detailed per-dependency health breakdowns. What changed: src/api/mod.rs — ready() handler - Database check retained as the first gate. - Horizon check added as the second gate: GET horizon_url with a hard 3-second timeout via tokio::time::timeout. Any non-5xx response is treated as reachable; a timeout or connection error returns 503 with a human-readable "reason" field. - Check is skipped entirely when STELLAR_GATEWAY_PUBLIC=UNCONFIGURED (no gateway configured, no on-chain work to do). - 503 body now carries a "reason" field so operators see exactly which dependency is down without reading logs. src/api/mod.rs — check_horizon_ready() (new helper) - Extracted into a dedicated async fn so both ready() and deps_health() call the same logic without duplication. - 3-second timeout is intentionally hard-coded: short enough to keep probe latency well inside any liveness/readiness check interval, long enough to absorb transient Horizon slowness. src/api/mod.rs — GET /deps (new endpoint) - Returns a JSON breakdown of each dependency individually: { "database": "ok", "horizon": "ok"|"unavailable"|"unconfigured" } plus background_tasks { healthy, failures } from the TaskHealth gauge. - Returns 503 when any dependency is unavailable or failure count > 0. - Designed for dashboards and alert rules that need to distinguish a DB failure from a Horizon failure. src/api/mod.rs — GET /metrics - Passes both webhook_metrics and task_health to metrics::render(). src/metrics.rs / src/lib.rs / src/main.rs - Full metrics + task-health foundation included (carries forward issues StellarGateLabs#170 and StellarGateLabs#171 as prerequisites). test and fixture updates - gateway_public changed to "UNCONFIGURED" in api_tests and rate_limit_tests make_config() so the Horizon check is skipped for unit tests that target an empty horizon_url. - AppState construction in all five integration test files and src/expiry.rs updated to supply webhook_metrics and task_health.
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.
The /ready endpoint previously only checked the database. A deployment with Horizon unreachable still reported ready, causing the load balancer to route traffic to an instance that cannot detect on-chain payments.
This change makes /ready check both the database AND Horizon before returning 200, and adds a dedicated /deps endpoint for detailed per-dependency health breakdowns.
What changed:
src/api/mod.rs — ready() handler
src/api/mod.rs — check_horizon_ready() (new helper)
src/api/mod.rs — GET /deps (new endpoint)
src/api/mod.rs — GET /metrics
src/metrics.rs / src/lib.rs / src/main.rs
test and fixture updates
closes #137