Skip to content

Define per-package default timeout constants and remove DEFAULT_TIMEOUT from torrust-tracker-configuration #1793

Closed

Description

@josecelano

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/receive
  • packages/axum-http-tracker-server: HTTP request processing via Tower's TimeoutLayer
  • packages/udp-tracker-server (tests): UDP client connections in contract tests
  • console/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:

  1. packages/tracker-client: evaluate usage, define local constant(s), update the one import site, drop torrust-tracker-configuration if it is the only remaining reason for the dep.
  2. packages/axum-http-tracker-server: evaluate usage, define local constant(s), update the one import site. Verify whether torrust-tracker-configuration can be dropped; drop it if so.
  3. packages/udp-tracker-server (test file): evaluate usage, define local constant(s) in the test module, update all 4 inline import sites. Verify whether torrust-tracker-configuration can be dropped from dev-dependencies; drop it if so.
  4. console/tracker-client: evaluate usage, define local constant(s) at crate level, update all 6 import sites, drop torrust-tracker-configuration.
  5. packages/configuration: once DEFAULT_TIMEOUT has zero consumers across the workspace, remove the constant and its associated use std::time::Duration; import if it becomes unused.
  6. Regenerate the workspace coupling report (docs/issues/open/1669-overhaul-packages/workspace-coupling-report.md) by running cargo 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_TIMEOUT to packages/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-client defines local timeout constant(s); no import from torrust_tracker_configuration; torrust-tracker-configuration removed from its Cargo.toml.
  • packages/axum-http-tracker-server defines local timeout constant(s); no import from torrust_tracker_configuration.
  • packages/udp-tracker-server test file defines local timeout constant(s); no import from torrust_tracker_configuration in tests.
  • console/tracker-client defines local timeout constant(s); no file in that package imports DEFAULT_TIMEOUT from torrust_tracker_configuration; torrust-tracker-configuration removed from its Cargo.toml.
  • packages/configuration/src/lib.rs no longer defines DEFAULT_TIMEOUT.
  • grep -r "torrust_tracker_configuration::DEFAULT_TIMEOUT" . --include="*.rs" returns zero matches.
  • cargo build --workspace succeeds with zero errors.
  • cargo test --workspace passes with zero failures.
  • linter all exits with code 0.
  • Workspace coupling report regenerated and committed.

Spec

docs/issues/open/1669-overhaul-packages/ (spec moved from drafts once issue is created)

Activity

  1. self-assigned this
    on May 19, 2026
  2. added 3 commits that reference this issue on May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions