refactor(primitives): move TrackerPolicy, TORRENT_PEERS_LIMIT, and PrivateMode from configuration to primitives#1865
Conversation
…ivateMode from configuration to primitives Moves three domain primitive types from `torrust-tracker-configuration` into `torrust-tracker-primitives` where they semantically belong. - Add `packages/primitives/src/policy.rs` with `TrackerPolicy` struct and `TORRENT_PEERS_LIMIT` constant - Add `packages/primitives/src/mode.rs` with `PrivateMode` struct - Export new modules from `torrust-tracker-primitives` lib - Remove types from `torrust-tracker-configuration` - Update all import sites in `tracker-core`, `swarm-coordination-registry`, and `torrent-repository-benchmarking` - Remove `torrust-tracker-configuration` dependency from `swarm-coordination-registry` and `torrent-repository-benchmarking` Closes torrust#1859
…EERS_LIMIT review
There was a problem hiding this comment.
Pull request overview
Moves tracker domain policy/mode primitives out of torrust-tracker-configuration and into torrust-tracker-primitives to reduce coupling across workspace crates (notably removing configuration as a dependency for swarm-coordination-registry and torrent-repository-benchmarking).
Changes:
- Added
policyandmodemodules totorrust-tracker-primitivesand re-exportedTrackerPolicy,TORRENT_PEERS_LIMIT, andPrivateMode. - Updated import sites across
tracker-core,swarm-coordination-registry, andtorrent-repository-benchmarkingto usetorrust-tracker-primitives. - Removed the now-unneeded
torrust-tracker-configurationdependencies from downstream crates and updated issue specs/docs.
Reviewed changes
Copilot reviewed 34 out of 35 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/primitives/src/policy.rs | New home for TrackerPolicy and TORRENT_PEERS_LIMIT in primitives. |
| packages/primitives/src/mode.rs | New home for PrivateMode in primitives. |
| packages/primitives/src/lib.rs | Exports new primitives modules and re-exports moved types/const. |
| packages/configuration/src/lib.rs | Removes TrackerPolicy and TORRENT_PEERS_LIMIT from configuration crate. |
| packages/configuration/src/v2_0_0/core.rs | Switches Core to use PrivateMode/TrackerPolicy from primitives and removes local PrivateMode. |
| packages/tracker-core/src/announce_handler.rs | Updates imports for TORRENT_PEERS_LIMIT to primitives. |
| packages/tracker-core/src/torrent/repository/in_memory.rs | Updates imports for TrackerPolicy/TORRENT_PEERS_LIMIT to primitives. |
| packages/tracker-core/src/authentication/mod.rs | Updates PrivateMode import to primitives in tests. |
| packages/tracker-core/src/authentication/service.rs | Updates PrivateMode import to primitives in tests. |
| packages/swarm-coordination-registry/src/swarm/coordinator.rs | Updates TrackerPolicy import to primitives. |
| packages/swarm-coordination-registry/src/swarm/registry.rs | Updates TrackerPolicy/TORRENT_PEERS_LIMIT imports to primitives (including tests). |
| packages/swarm-coordination-registry/Cargo.toml | Removes direct dependency on torrust-tracker-configuration. |
| packages/torrent-repository-benchmarking/Cargo.toml | Removes direct dependency on torrust-tracker-configuration. |
| packages/torrent-repository-benchmarking/tests/repository/mod.rs | Updates TrackerPolicy import to primitives for tests. |
| packages/torrent-repository-benchmarking/tests/entry/mod.rs | Updates TrackerPolicy/TORRENT_PEERS_LIMIT imports to primitives for tests. |
| packages/torrent-repository-benchmarking/tests/common/torrent.rs | Updates TrackerPolicy import to primitives in shared test helpers. |
| packages/torrent-repository-benchmarking/tests/common/repo.rs | Updates TrackerPolicy import to primitives in shared test helpers. |
| packages/torrent-repository-benchmarking/src/repository/skip_map_mutex_std.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio_mutex_tokio.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio_mutex_std.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/repository/rw_lock_std.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/repository/rw_lock_std_mutex_tokio.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/repository/rw_lock_std_mutex_std.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/repository/mod.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/repository/dash_map_mutex_std.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/entry/single.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/entry/rw_lock_parking_lot.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/entry/mutex_tokio.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/entry/mutex_std.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/entry/mutex_parking_lot.rs | Updates TrackerPolicy import to primitives. |
| packages/torrent-repository-benchmarking/src/entry/mod.rs | Updates TrackerPolicy import to primitives. |
| docs/issues/open/1864-1669-review-torrent-peers-limit/ISSUE.md | Adds follow-up spec for deciding whether TORRENT_PEERS_LIMIT should remain a constant. |
| docs/issues/closed/1859-1669-move-tracker-policy-and-private-mode-to-primitives/ISSUE.md | Marks issue spec as closed and checks acceptance criteria. |
| Cargo.lock | Removes torrust-tracker-configuration deps where no longer required. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// When true, if the keys is not permanent the expiration date will be | ||
| /// ignored. The key will be accepted even if it has expired. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1865 +/- ##
===========================================
- Coverage 77.80% 77.79% -0.01%
===========================================
Files 380 382 +2
Lines 28648 28648
Branches 28648 28648
===========================================
- Hits 22290 22288 -2
+ Misses 6052 6051 -1
- Partials 306 309 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Fix doc link in axum-http-server/src/lib.rs: TORRENT_PEERS_LIMIT now lives in torrust_tracker_primitives (was torrust_tracker_configuration) - Fix spelling: 'localised' -> 'localized' in issue torrust#1864 spec - Mark FU-1 completed in DECISIONS.md DEC-07 (done in torrust#1859, PR torrust#1865) - Update EPIC.md footnote: 'will be moved' -> 'were moved'
|
ACK 736a535 |
Summary
Closes #1859. Sub-task of #1669.
Moves three types out of
torrust-tracker-configurationand intotorrust-tracker-primitives:TrackerPolicystructTORRENT_PEERS_LIMITconstantPrivateModestructThis breaks the dependency that
swarm-coordination-registryandtorrent-repository-benchmarkinghad on the configuration crate purely for these domain types.Changes
New files
packages/primitives/src/policy.rs— definesTrackerPolicyandTORRENT_PEERS_LIMITpackages/primitives/src/mode.rs— definesPrivateModeModified files
packages/primitives/src/lib.rs— exports new modulespackages/configuration/src/lib.rs— removesTrackerPolicyandTORRENT_PEERS_LIMITpackages/configuration/src/v2_0_0/core.rs— removesPrivateMode, updates importspackages/tracker-core/src/announce_handler.rs— updates importspackages/tracker-core/src/torrent/repository/in_memory.rs— updates importspackages/tracker-core/src/authentication/mod.rs— updates importspackages/tracker-core/src/authentication/service.rs— updates importspackages/swarm-coordination-registry/src/swarm/coordinator.rs— updates importspackages/swarm-coordination-registry/src/swarm/registry.rs— updates importspackages/swarm-coordination-registry/Cargo.toml— removestorrust-tracker-configurationdependencypackages/torrent-repository-benchmarking/Cargo.toml— removestorrust-tracker-configurationdependencytorrent-repository-benchmarking/src/andtests/files — updates importsFollow-up
Issue #1864 tracks a follow-up decision on whether
TORRENT_PEERS_LIMITshould become a runtime config option rather than a compile-time constant.Testing
cargo test --workspace✅ all passcargo clippy --workspace -- -D warnings✅ no warningslinter all✅ passcargo machete✅ pass