fix: bounded event bus, JSON tracing, graceful shutdown, embedded migrations - #741
Merged
EDOHWARES merged 2 commits intoAug 1, 2026
Conversation
…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
|
@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! 🚀 |
# Conflicts: # core/Cargo.toml
Collaborator
|
Nice implementation, LGTM! |
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.
Addresses four backend reliability and observability issues.
Changes
#565 — Bounded WebSocket event channel with backpressure
SimulationBus::with_capacity(n)constructor; capacity is clamped to[16, 65536]event_bus_capacityfield toAppConfigwith default 256 and.set_default()inload_config()main()now creates the bus withSimulationBus::with_capacity(config.event_bus_capacity)so the buffer size is tunable viaEVENT_BUS_CAPACITYenv varRecvError::Lagged(existing drop-and-continue backpressure is preserved)#572 — Structured JSON logging + x-request-id correlation
jsonfeature totracing-subscriberinCargo.tomllog_format_json: booltoAppConfig; whenLOG_FORMAT=jsonthe subscriber is initialised with.json()layer instead of the default human-readable layerrequest-idandset-headerfeatures totower-httpSetRequestIdLayer::x_request_id(MakeRequestUuid)andPropagateRequestIdLayer::x_request_id()into the router so every request receives anx-request-idUUID header echoed back in the response#573 — SIGTERM / SIGINT graceful shutdown
axum::serve(...).awaitwith.with_graceful_shutdown(shutdown_signal())shutdown_signal()usestokio::signal::ctrl_c(all platforms) andtokio::signal::unix::SignalKind::terminate(Unix) viatokio::select!— whichever arrives first triggers a clean drain#575 — Embedded SQL migrations
sqlx::migrate!()was already present inmain()readingcore/migrations/at compile time and applying pending migrations on every startupCloses #565
Closes #572
Closes #573
Closes #575