Description
Before the SDK makes any Horizon API call, it should proactively verify that the configured Horizon endpoint is reachable and returning a healthy response. This is especially important at startup and after network configuration changes. A lightweight availability prober should periodically hit the Horizon root endpoint (/), parse the history_latest_ledger field, and mark the endpoint as degraded or unavailable when the response is stale or the call fails.
Technical Context
Add src/horizonProber.ts. Calls @stellar/stellar-sdk Server.fetchRoot() to obtain HorizonApi.RootResponse. Tracks history_latest_ledger and compares it against the expected cadence (new ledger every ~5 s). Integrates with src/health.ts and src/healthDashboard.ts. Emits horizonEndpointDegraded and horizonEndpointRecovered via src/events.ts. Configured as a step in src/loadBalancer.ts health checks.
Acceptance Criteria
Description
Before the SDK makes any Horizon API call, it should proactively verify that the configured Horizon endpoint is reachable and returning a healthy response. This is especially important at startup and after network configuration changes. A lightweight availability prober should periodically hit the Horizon root endpoint (
/), parse thehistory_latest_ledgerfield, and mark the endpoint as degraded or unavailable when the response is stale or the call fails.Technical Context
Add
src/horizonProber.ts. Calls@stellar/stellar-sdkServer.fetchRoot()to obtainHorizonApi.RootResponse. Trackshistory_latest_ledgerand compares it against the expected cadence (new ledger every ~5 s). Integrates withsrc/health.tsandsrc/healthDashboard.ts. EmitshorizonEndpointDegradedandhorizonEndpointRecoveredviasrc/events.ts. Configured as a step insrc/loadBalancer.tshealth checks.Acceptance Criteria
HorizonProber.probe(endpointUrl): Promise<ProbeResult>returns{ reachable, latencyMs, latestLedger, isStale }withintimeoutMsisStaleistruewhenhistory_latest_ledgerhas not advanced instalenessThresholdMs(configurable, default 30 000 ms)horizonEndpointDegradedwhen two consecutive probes fail or return stale resultshorizonEndpointRecoveredon the first successful non-stale probe after a degraded periodsrc/healthDashboard.tsincludes the prober's last result in the dashboard snapshot