Repository navigation
refactor(env): narrow EnvContainer::initialize to accept per-service config slices - #1866
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the UDP and Axum HTTP server “environment” initialization APIs to accept only the configuration slices each service needs (Arc<Core> + per-service config), reducing cross-package configuration coupling as described in DEC-09 / issue #1861.
Changes:
- Narrowed
Environment::new/EnvContainer::initializefor UDP and HTTP servers to take(&Arc<Core>, &Arc<UdpTracker|HttpTracker>)instead of&Arc<Configuration>. - Updated test call sites to extract and pass the per-service config slices.
- Rewrote UDP/HTTP example binaries to construct
Core+ per-service config directly (noConfigurationaggregate), and documented DEC-09 / closed the issue spec.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/udp-server/src/environment.rs | Narrows environment/container initialization to Core + UdpTracker and removes bundled global logging init. |
| packages/axum-http-server/src/environment.rs | Narrows environment/container initialization to Core + HttpTracker and removes bundled global logging init. |
| packages/udp-server/tests/server/contract.rs | Updates UDP contract tests to pass Arc<Core> + Arc<UdpTracker>. |
| packages/axum-http-server/tests/server/v1/contract.rs | Updates HTTP v1 contract tests to pass Arc<Core> + Arc<HttpTracker> (many call sites). |
| packages/axum-health-check-api-server/tests/server/contract.rs | Updates health-check tests to construct and pass config slices to UDP/HTTP servers. |
| packages/udp-server/examples/udp_only_public_tracker.rs | Updates example to build Core + UdpTracker directly and use the narrowed API. |
| packages/axum-http-server/examples/http_only_public_tracker.rs | Updates example to build Core + HttpTracker directly and use the narrowed API. |
| docs/issues/open/1669-overhaul-packages/DECISIONS.md | Adds DEC-09 documenting the decision/rationale and artifacts. |
| docs/issues/open/1861-1669-narrow-envcontainer-initialize-config-slices/ISSUE.md | Marks issue closed and checks acceptance criteria (but has a future last-updated-utc). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1866 +/- ##
===========================================
- Coverage 77.79% 77.78% -0.02%
===========================================
Files 382 382
Lines 28648 28637 -11
Branches 28648 28637 -11
===========================================
- Hits 22288 22275 -13
- Misses 6051 6054 +3
+ Partials 309 308 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…config slices Instead of accepting the full `&Arc<Configuration>` aggregate, the `EnvContainer::initialize` and `Environment::new` constructors for the UDP and HTTP server environments now accept only the config slices they actually need: - `UdpTrackerEnvironment::new` now takes `(&Arc<Core>, &Arc<UdpTracker>)` - `HttpTrackerEnvironment::new` now takes `(&Arc<Core>, &Arc<HttpTracker>)` This prevents idle config types (`HttpTracker`, `UdpTracker`, `HttpApi`, `HealthCheckApi`, `TslConfig`, `AccessTokens`) from being compiled into binaries that do not use them. Updated all call sites: 6 in udp-server tests, 50 in axum-http-server tests, 4 in axum-health-check-api-server tests, and both Cargo examples. Decision recorded as DEC-09 in docs/issues/open/1669-overhaul-packages/DECISIONS.md. Issue torrust#1861 closed. Closes torrust#1861
bd5499e to
cf67dea
Compare
|
ACK cf67dea |
Summary
Closes #1861.
Implements DEC-09 from EPIC #1669: narrows the initialization API of
EnvContainer(and related server environment types) to accept specific config slices instead of the fullConfigurationaggregate.What changed
packages/udp-server/src/environment.rsEnvironment::newandEnvContainer::initializenow accept(&Arc<Core>, &Arc<UdpTracker>)instead of&Arc<Configuration>initialize_global_servicescall removed (callers manage logging/clock setup independently)packages/axum-http-server/src/environment.rs(&Arc<Core>, &Arc<HttpTracker>)instead of&Arc<Configuration>Call sites updated
packages/udp-server/tests/server/contract.rs— 6 call sitespackages/axum-http-server/tests/server/v1/contract.rs— 50 call sitespackages/axum-health-check-api-server/tests/server/contract.rs— 4 call sitesExamples rewritten
packages/udp-server/examples/udp_only_public_tracker.rs— now usesCore+UdpTrackerdirectly;Configurationaggregate is not importedpackages/axum-http-server/examples/http_only_public_tracker.rs— now usesCore+HttpTrackerdirectlyDocs
docs/issues/open/1669-overhaul-packages/DECISIONS.md— DEC-09 addeddocs/issues/open/1861-1669-narrow-envcontainer-initialize-config-slices/ISSUE.md— closed, all acceptance criteria checkedOut of scope
axum-rest-api-serverenvironment: intentionally not narrowed — it legitimately needsCore,HttpTracker,UdpTracker, andHttpApito expose full tracker status via the REST API.src/bootstrap/(main binary): unaffected — usesAppContainer::initialize, notEnvironment::newdirectly.