Skip to content

fix: ping every broker in the FastStream health check - #296

Merged
lesnik512 merged 1 commit into
mainfrom
fix/faststream-health-all-brokers
Oct 22, 2026
Merged

lesnik512 merged 1 commit into
mainfrom
fix/faststream-health-all-brokers

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Closes #293.

The FastStream health check pinged only application.broker, which FastStream defines as brokers[0]. An app with a second broker, added with add_broker or passed to AsgiFastStream directly, reported healthy while that broker was down.

The check now pings every broker in application.brokers and reports healthy only when all of them return True. The pings run concurrently through asyncio.gather, each with faststream_health_check_broker_timeout, so the route still waits at most one timeout, not one per broker. With a single broker the behavior is unchanged. With no broker the route still reports unhealthy. Response bodies and status codes are unchanged.

brokers exists from FastStream 0.6, so the faststream>=0.6 floor stays.

Tests, written first and failing before the fix:

  • two brokers where the second ping returns False: 500
  • two brokers that both answer: 200, each ping called once with the configured timeout

Out of scope: the OpenTelemetry, Prometheus and logging instruments that also see only the first broker (#295).

@lesnik512
lesnik512 merged commit d3bb240 into main Oct 22, 2026
30 checks passed
@lesnik512
lesnik512 deleted the fix/faststream-health-all-brokers branch October 22, 2026 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastStream health check pings only the first broker of a multi-broker app

1 participant