feat(udp-core, udp-server, configuration): add trait abstractions for REST API decoupling (SI-30) - #1933
Conversation
There was a problem hiding this comment.
Pull request overview
This PR advances EPIC #1669 (SI-30) by extracting UDP-side trait abstractions and moving the connection-id error ban threshold from a hardcoded constant into configuration, laying groundwork for later REST decoupling (SI-33).
Changes:
- Introduces trait abstractions for UDP core/server stats repositories and banning stats.
- Replaces
MAX_CONNECTION_ID_ERRORS_PER_IPwithUdpTracker.max_connection_id_errors_per_ip(defaulted via serde). - Wires the new config field through containers/examples/tests and adds
async-traitwhere needed.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/container.rs | Plumbs max_connection_id_errors_per_ip into UDP core services init. |
| packages/udp-server/src/statistics/repository.rs | Adds UdpServerStatsRepository trait and implements it for the concrete repository. |
| packages/udp-server/examples/udp_only_public_tracker.rs | Adds the new UDP tracker config field in the example. |
| packages/udp-server/Cargo.toml | Adds async-trait dependency for the new trait object pattern. |
| packages/udp-core/src/statistics/repository.rs | Adds UdpCoreStatsRepository trait and implements it for the concrete repository. |
| packages/udp-core/src/services/banning.rs | Adds BanningStats trait implemented by BanService. |
| packages/udp-core/src/lib.rs | Removes the hardcoded MAX_CONNECTION_ID_ERRORS_PER_IP constant. |
| packages/udp-core/src/container.rs | Threads the configured threshold into BanService initialization. |
| packages/udp-core/Cargo.toml | Adds async-trait dependency for the new trait object pattern. |
| packages/test-helpers/src/configuration.rs | Updates ephemeral config builder with the new UDP config field. |
| packages/rest-api-core/src/statistics/services.rs | Removes dependency on the deleted constant in tests. |
| packages/configuration/src/v2_0_0/udp_tracker.rs | Adds max_connection_id_errors_per_ip config field with serde default. |
| Cargo.lock | Locks async-trait into the workspace dependency graph. |
Comments suppressed due to low confidence (1)
packages/udp-server/examples/udp_only_public_tracker.rs:68
- This example now sets additional
UdpTrackerfields, but the runtime output still claimsUdpTrackeris only “bind address, cookie lifetime”. Updating the printed description avoids confusing users running the example.
max_connection_id_errors_per_ip: 10,
};
println!("Types from torrust-tracker-configuration used by this binary:");
println!(" Core — tracker domain settings");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1933 +/- ##
===========================================
+ Coverage 79.46% 79.51% +0.05%
===========================================
Files 324 324
Lines 23116 23137 +21
Branches 23116 23137 +21
===========================================
+ Hits 18369 18398 +29
+ Misses 4476 4468 -8
Partials 271 271 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bc3bdf5 to
c881f87
Compare
… REST API decoupling (SI-30) - Add BanningStats trait in udp-core services/banning.rs - Add UdpCoreStatsRepository trait in udp-core statistics - Add UdpServerStatsRepository trait in udp-server statistics - Add max_connection_id_errors_per_ip config field to UdpTracker - Update UdpTrackerCoreServices to use config value instead of constant - Remove pub const MAX_CONNECTION_ID_ERRORS_PER_IP from udp-core lib.rs - Add async-trait dependency to udp-core and udp-server
c881f87 to
637c17b
Compare
|
ACK 637c17b |
Summary
Spec review for EPIC #1669 subissues SI-30 and SI-33:
SI-30 (#1924) — narrowed scope
BanningStats,UdpCoreStatsRepository,UdpServerStatsRepository)MAX_CONNECTION_ID_ERRORS_PER_IP→ config optionSI-33 (#1930) — new open issue
docs/issues/drafts/1669-define-rest-api-contract-first-package-architecture.mddocs/issues/open/1930-1669-si-33-rest-api-contract-first-architecture.mdEPIC.md
rest-api-core → udp-serverdependency from "layer violation" to "cross-service orchestration dep"Pre-merge checks
cargo machete— passlinter all— passcargo test --doc --workspace— passcargo +nightly fmt --check— passcargo +nightly check --all-targets --all-features— passcargo +stable test --all-targets --all-features— pass