Repository navigation
Description
Goal
Replace the shared DEFAULT_TIMEOUT constant in packages/configuration with per-package
timeout constants, each named to reflect the specific operation context of its package.
Remove DEFAULT_TIMEOUT from packages/configuration entirely once all consumers have
defined their own constant.
Background
DEFAULT_TIMEOUT is a Duration constant (Duration::from_secs(5)), defined in
packages/configuration/src/lib.rs. It is not used within the configuration package
itself — it exists solely for other packages to import.
A single generic timeout shared across the entire workspace is too coarse-grained. Each
package performs a different kind of network operation:
packages/tracker-client: UDP socket connect/send/receivepackages/axum-http-tracker-server: HTTP request processing via Tower'sTimeoutLayerpackages/udp-tracker-server(tests): UDP client connections in contract testsconsole/tracker-client: network checking (UDP, HTTP, health checks) in a CLI tool
Each package should own its timeout default with a name that reflects its specific context.
Sharing a constant from the configuration crate creates an unnecessary coupling — packages
that have no other reason to depend on torrust-tracker-configuration are forced to do so
solely for a timeout value.
This issue is a subissue of EPIC #1669 (Overhaul: Packages).
Scope
For each of the 4 consumer packages, in order:
packages/tracker-client: evaluate usage, define local constant(s), update the one import site, droptorrust-tracker-configurationif it is the only remaining reason for the dep.packages/axum-http-tracker-server: evaluate usage, define local constant(s), update the one import site. Verify whethertorrust-tracker-configurationcan be dropped; drop it if so.packages/udp-tracker-server(test file): evaluate usage, define local constant(s) in the test module, update all 4 inline import sites. Verify whethertorrust-tracker-configurationcan be dropped fromdev-dependencies; drop it if so.console/tracker-client: evaluate usage, define local constant(s) at crate level, update all 6 import sites, droptorrust-tracker-configuration.packages/configuration: onceDEFAULT_TIMEOUThas zero consumers across the workspace, remove the constant and its associateduse std::time::Duration;import if it becomes unused.- Regenerate the workspace coupling report (
docs/issues/open/1669-overhaul-packages/workspace-coupling-report.md) by runningcargo run -p workspace-coupling.
Per-package evaluation rule: before defining the local constant(s), review how DEFAULT_TIMEOUT is used within the package. If it is used for two or more semantically distinct operations (for example, "sending/receiving data" vs. "waiting for a socket to become readable or writable"), define a separate named constant for each distinct purpose rather than a single generic timeout.
Out of Scope
- Moving
DEFAULT_TIMEOUTtopackages/clock— superseded by this approach. - Any API or behaviour changes beyond replacing the import source.
- Changing timeout values — all local constants use the same
Duration::from_secs(5).
Implementation Plan
| ID | Task | Notes |
|---|---|---|
| T1 | packages/tracker-client: evaluate DEFAULT_TIMEOUT usage; define local constant(s) |
Candidates: DEFAULT_UDP_TIMEOUT |
| T2 | packages/tracker-client: remove use torrust_tracker_configuration::DEFAULT_TIMEOUT |
Use local constant(s); cargo build -p bittorrent-tracker-client succeeds |
| T3 | packages/tracker-client: drop torrust-tracker-configuration from Cargo.toml |
cargo machete confirms clean |
| T4 | packages/axum-http-tracker-server: evaluate usage; define local constant(s) |
Candidates: DEFAULT_REQUEST_TIMEOUT |
| T5 | packages/axum-http-tracker-server: remove use torrust_tracker_configuration::DEFAULT_TIMEOUT |
Use local constant(s); drop dep if possible |
| T6 | packages/udp-tracker-server (tests): evaluate usage; define local constant(s) |
Review 4 use sites; candidates: DEFAULT_UDP_TIMEOUT |
| T7 | packages/udp-tracker-server (tests): remove all 4 use torrust_tracker_configuration::DEFAULT_TIMEOUT |
Drop from dev-dependencies if possible |
| T8 | console/tracker-client: evaluate usage; define local constant(s) |
Review 6 use sites across UDP, HTTP, health-check contexts; candidates: DEFAULT_NETWORK_TIMEOUT |
| T9 | console/tracker-client: update all 6 import sites to use the local constant(s) |
Remove all use torrust_tracker_configuration::DEFAULT_TIMEOUT imports |
| T10 | console/tracker-client: drop torrust-tracker-configuration from Cargo.toml |
cargo machete confirms clean |
| T11 | packages/configuration: remove DEFAULT_TIMEOUT and its Duration import if unused |
Zero consumers remaining; cargo build --workspace succeeds |
| T12 | Run cargo build --workspace and cargo test --workspace |
Clean build; all tests pass |
| T13 | Run linter all |
Exit code 0 |
| T14 | Regenerate workspace coupling report | cargo run -p workspace-coupling; updates docs/issues/open/1669-overhaul-packages/workspace-coupling-report.md |
Acceptance Criteria
-
packages/tracker-clientdefines local timeout constant(s); no import fromtorrust_tracker_configuration;torrust-tracker-configurationremoved from itsCargo.toml. -
packages/axum-http-tracker-serverdefines local timeout constant(s); no import fromtorrust_tracker_configuration. -
packages/udp-tracker-servertest file defines local timeout constant(s); no import fromtorrust_tracker_configurationin tests. -
console/tracker-clientdefines local timeout constant(s); no file in that package importsDEFAULT_TIMEOUTfromtorrust_tracker_configuration;torrust-tracker-configurationremoved from itsCargo.toml. -
packages/configuration/src/lib.rsno longer definesDEFAULT_TIMEOUT. -
grep -r "torrust_tracker_configuration::DEFAULT_TIMEOUT" . --include="*.rs"returns zero matches. -
cargo build --workspacesucceeds with zero errors. -
cargo test --workspacepasses with zero failures. -
linter allexits with code0. - Workspace coupling report regenerated and committed.
Spec
docs/issues/open/1669-overhaul-packages/ (spec moved from drafts once issue is created)
Activity
docs(issues): add issue specification for #1793
Merge #1794: feat(configuration): define per-package default timeout …
chore(issues): archive closed issue specs #1790, #1793, #1795, #1797, #…
Merge #1812: chore(issues): archive closed issue specs to docs/issues…
feat(configuration): define per-package default timeout constants (to…