Skip to content

fix: bounded event bus, JSON tracing, graceful shutdown, embedded migrations - #741

Merged
EDOHWARES merged 2 commits into
SoroLabs:mainfrom
10xwhoman:fix/backpressure-tracing-shutdown-migrations
Aug 1, 2026
Merged

fix: bounded event bus, JSON tracing, graceful shutdown, embedded migrations#741
EDOHWARES merged 2 commits into
SoroLabs:mainfrom
10xwhoman:fix/backpressure-tracing-shutdown-migrations

Conversation

@10xwhoman

Copy link
Copy Markdown
Contributor

Addresses four backend reliability and observability issues.

Changes

#565 — Bounded WebSocket event channel with backpressure

  • Added SimulationBus::with_capacity(n) constructor; capacity is clamped to [16, 65536]
  • Added event_bus_capacity field to AppConfig with default 256 and .set_default() in load_config()
  • main() now creates the bus with SimulationBus::with_capacity(config.event_bus_capacity) so the buffer size is tunable via EVENT_BUS_CAPACITY env var
  • Slow subscribers still receive RecvError::Lagged (existing drop-and-continue backpressure is preserved)

#572 — Structured JSON logging + x-request-id correlation

  • Added json feature to tracing-subscriber in Cargo.toml
  • Added log_format_json: bool to AppConfig; when LOG_FORMAT=json the subscriber is initialised with .json() layer instead of the default human-readable layer
  • Added request-id and set-header features to tower-http
  • Wired SetRequestIdLayer::x_request_id(MakeRequestUuid) and PropagateRequestIdLayer::x_request_id() into the router so every request receives an x-request-id UUID header echoed back in the response

#573 — SIGTERM / SIGINT graceful shutdown

  • Replaced axum::serve(...).await with .with_graceful_shutdown(shutdown_signal())
  • shutdown_signal() uses tokio::signal::ctrl_c (all platforms) and tokio::signal::unix::SignalKind::terminate (Unix) via tokio::select! — whichever arrives first triggers a clean drain
  • Logs which signal caused shutdown

#575 — Embedded SQL migrations

  • sqlx::migrate!() was already present in main() reading core/migrations/ at compile time and applying pending migrations on every startup
  • This commit documents the existing behaviour for traceability

Closes #565
Closes #572
Closes #573
Closes #575

…rations

- SoroLabs#565: make SimulationBus channel capacity configurable via EVENT_BUS_CAPACITY
  env var (AppConfig); add SimulationBus::with_capacity() clamped to [16,65536];
  slow subscribers still receive RecvError::Lagged (drop-and-continue backpressure)
- SoroLabs#572: add LOG_FORMAT=json support via tracing-subscriber json feature; add
  x-request-id middleware (SetRequestIdLayer + PropagateRequestIdLayer from
  tower-http request-id feature) to assign and echo a UUID per request
- SoroLabs#573: replace axum::serve(...).await with .with_graceful_shutdown(shutdown_signal())
  so SIGTERM and SIGINT both trigger a clean drain before process exit; logs
  which signal caused shutdown
- SoroLabs#575: embedded SQL migrations via sqlx::migrate!() were already in place;
  documented in this commit for traceability (sqlx reads core/migrations/ at
  compile time and runs pending migrations on startup)

Closes SoroLabs#565
Closes SoroLabs#572
Closes SoroLabs#573
Closes SoroLabs#575
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@10xwhoman Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@EDOHWARES

Copy link
Copy Markdown
Collaborator

Nice implementation, LGTM!

@EDOHWARES
EDOHWARES merged commit bd7523b into SoroLabs:main Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants