Skip to content

Commit 9f8ab59

Browse files
committed
feat(clock): move DurationSinceUnixEpoch to torrust-tracker-clock (torrust#1790)
Move the `DurationSinceUnixEpoch` type alias from `torrust-tracker-primitives` into `torrust-tracker-clock`, where it semantically belongs as it measures time relative to the Unix epoch — a clock-domain concept. Changes: - `torrust-tracker-clock`: add `pub type DurationSinceUnixEpoch = std::time::Duration` - `torrust-tracker-clock/Cargo.toml`: remove `torrust-tracker-primitives` dependency - `torrust-tracker-primitives/src/lib.rs`: replace type definition with `#[deprecated] pub use torrust_tracker_clock::DurationSinceUnixEpoch` for backward compatibility - `torrust-tracker-primitives/src/peer.rs`: import `DurationSinceUnixEpoch` directly from `torrust_tracker_clock` to avoid triggering the deprecation warning internally - `torrust-tracker-metrics/Cargo.toml`: replace `torrust-tracker-primitives` dep with `torrust-tracker-clock` - All workspace consumers (77 files): update import path from `torrust_tracker_primitives::DurationSinceUnixEpoch` to `torrust_tracker_clock::DurationSinceUnixEpoch` - Issue spec and EPIC updated Resolves torrust#1790.
1 parent 5affd26 commit 9f8ab59

90 files changed

Lines changed: 195 additions & 143 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/issues/open/1669-overhaul-packages/EPIC.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ rule priority.
205205
Status: TODO unless noted. `SI-XX` = recommended implementation sequence number.
206206

207207
- [ ] SI-01 — Establish baseline: dependency graph + README audit _(analysis; no blockers; informs all other subissues)_
208-
- [ ] SI-02 — Move `DurationSinceUnixEpoch` from `torrust-tracker-primitives` to `torrust-tracker-clock` _(Rule M; no hard blockers)_
208+
- [x] SI-02 — Move `DurationSinceUnixEpoch` from `torrust-tracker-primitives` to `torrust-tracker-clock` _(Rule M; no hard blockers)_
209209
- [ ] SI-03 — Move `DEFAULT_TIMEOUT` from `torrust-tracker-configuration` to `torrust-tracker-clock` _(Rule M; no blockers)_
210210
- [ ] SI-04 — Move `AnnouncePolicy` from `torrust-tracker-configuration` to `torrust-tracker-primitives` _(Rule M; no blockers)_
211211
- [ ] SI-05 — Create `torrust-net-primitives` and move `ServiceBinding` from `torrust-tracker-primitives` _(Rule M + new package; no blockers)_
@@ -225,7 +225,7 @@ Details:
225225
| SI | Issue | Local Spec | Status | Notes |
226226
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------ | ------------------------------------------------------------------------------------------------------------ |
227227
| SI-01 | #TBD — Establish baseline: dependency graph + README audit | [docs/issues/drafts/1669-01-establish-baseline-analysis.md](../../drafts/1669-01-establish-baseline-analysis.md) | TODO | No blockers; informs extraction decisions |
228-
| SI-02 | [#1790](https://github.com/torrust/torrust-tracker/issues/1790) — Move `DurationSinceUnixEpoch` from `torrust-tracker-primitives` to `torrust-tracker-clock` | [docs/issues/open/1790-move-duration-since-unix-epoch-to-torrust-tracker-clock.md](../../open/1790-move-duration-since-unix-epoch-to-torrust-tracker-clock.md) | TODO | Rule M; no hard blockers; prerequisite for SI-13 |
228+
| SI-02 | [#1790](https://github.com/torrust/torrust-tracker/issues/1790) — Move `DurationSinceUnixEpoch` from `torrust-tracker-primitives` to `torrust-tracker-clock` | [docs/issues/open/1790-move-duration-since-unix-epoch-to-torrust-tracker-clock.md](../../open/1790-move-duration-since-unix-epoch-to-torrust-tracker-clock.md) | DONE | Rule M; no hard blockers; prerequisite for SI-13 |
229229
| SI-03 | #TBD — Move `DEFAULT_TIMEOUT` from `torrust-tracker-configuration` to `torrust-tracker-clock` | [docs/issues/drafts/1669-03-move-default-timeout-from-configuration-to-clock.md](../../drafts/1669-03-move-default-timeout-from-configuration-to-clock.md) | TODO | Rule M; no blockers; prerequisite for SI-09 (clock rename) |
230230
| SI-04 | #TBD — Move `AnnouncePolicy` from `torrust-tracker-configuration` to `torrust-tracker-primitives` | [docs/issues/drafts/1669-04-move-announce-policy-to-torrust-tracker-primitives.md](../../drafts/1669-04-move-announce-policy-to-torrust-tracker-primitives.md) | TODO | Rule M; fixes inverted dep (primitives → configuration); no blockers |
231231
| SI-05 | #TBD — Create `torrust-net-primitives` and move `ServiceBinding` from `torrust-tracker-primitives` | [docs/issues/drafts/1669-05-create-torrust-net-primitives-and-move-service-binding.md](../../drafts/1669-05-create-torrust-net-primitives-and-move-service-binding.md) | TODO | Rule M + new package; generic networking type; breaks server-lib → tracker-primitives dep |
@@ -334,8 +334,8 @@ against this constraint (verified May 2026).
334334
| `torrust-tracker-contrib-bencode` | Yes | None | ✅ Now | Extraction subissue exists; no blockers |
335335
| `bittorrent-peer-id` | No | None | ✅ Now | No spec yet; can be extracted first in the `bittorrent-*` sequence |
336336
| `torrust-tracker-located-error` | Yes | None | ✅ Already published | No extraction spec yet |
337-
| `torrust-tracker-clock` (→ `torrust-clock`) | Yes | `torrust-tracker-primitives` (published ✅); `DurationSinceUnixEpoch` will be removed by follow-up subissue | ✅ After rename + move | See [extract clock subissue](../../drafts/1669-13-extract-torrust-clock-to-standalone-repo.md) |
338-
| `torrust-tracker-metrics` (→ `torrust-metrics`) | No | `torrust-tracker-primitives` (published ✅) | ✅ After rename | See [extract metrics subissue](../../drafts/1669-14-extract-torrust-metrics-to-standalone-repo.md) |
337+
| `torrust-tracker-clock` (→ `torrust-clock`) | Yes | None (✅ `torrust-tracker-primitives` dep removed by SI-02 #1790) | ✅ After rename | See [extract clock subissue](../../drafts/1669-13-extract-torrust-clock-to-standalone-repo.md) |
338+
| `torrust-tracker-metrics` (→ `torrust-metrics`) | No | `torrust-tracker-clock` (published ✅; was `torrust-tracker-primitives` — removed by SI-02 #1790) | ✅ After rename | See [extract metrics subissue](../../drafts/1669-14-extract-torrust-metrics-to-standalone-repo.md) |
339339
| `bittorrent-udp-tracker-protocol` | No | `bittorrent-peer-id` (not published) || After `bittorrent-peer-id` |
340340
| `bittorrent-tracker-core` | No | `torrust-tracker-events`, `torrust-tracker-metrics`, `torrust-tracker-swarm-coordination-registry`, `torrust-rest-tracker-api-client` (all unpublished) | ❌ Very deep chain | After all four above; also has `torrust-rest-tracker-api-client` as a runtime dep — a layer violation worth resolving before extraction |
341341
| `bittorrent-http-tracker-protocol` | No | `bittorrent-udp-tracker-protocol`, `bittorrent-tracker-core` (both unpublished) || After `bittorrent-udp-tracker-protocol` and `bittorrent-tracker-core` |

docs/issues/open/1790-move-duration-since-unix-epoch-to-torrust-tracker-clock.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ github-issue: 1790
77
spec-path: docs/issues/open/1790-move-duration-since-unix-epoch-to-torrust-tracker-clock.md
88
branch: 1790-move-duration-since-unix-epoch
99
related-pr: null
10-
last-updated-utc: 2026-05-18 00:00
10+
last-updated-utc: 2026-06-24 00:00
1111
semantic-links:
1212
skill-links:
1313
- create-issue
@@ -97,14 +97,14 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`.
9797

9898
| ID | Status | Task | Notes / Expected Output |
9999
| --- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
100-
| T1 | TODO | Define `DurationSinceUnixEpoch` in `packages/clock/src/lib.rs` | `pub type DurationSinceUnixEpoch = std::time::Duration;` |
101-
| T2 | TODO | Update `packages/clock/src/clock/mod.rs` and `packages/clock/src/conv/mod.rs` to use the local definition | Replace `use torrust_tracker_primitives::DurationSinceUnixEpoch` with local import |
102-
| T3 | TODO | Remove `torrust-tracker-primitives` dep from `packages/clock/Cargo.toml` | Dep entry removed; workspace build still passes |
103-
| T4 | TODO | Update all 80+ workspace files to import `DurationSinceUnixEpoch` from `torrust_tracker_clock` instead of `torrust_tracker_primitives` | Use M1 grep to find the full file list; one-line change per file |
104-
| T5 | TODO | Run `cargo build --workspace` and `cargo test --workspace` | Clean build and all tests pass |
105-
| T6 | TODO | Run `linter all` | Exit code `0` |
106-
| T7 | TODO | Update EPIC #1669 extraction ordering table: note that `torrust-tracker-clock` has no `torrust-tracker-primitives` dep | `torrust-tracker-clock` row: `torrust-tracker-primitives` dep removed |
107-
| T8 | TODO | Update `torrust-tracker-metrics`: replace import of `DurationSinceUnixEpoch` from `torrust_tracker_primitives` with `torrust_tracker_clock`; remove `torrust-tracker-primitives` dep from its `Cargo.toml` if no longer needed | `cargo build -p torrust-tracker-metrics` succeeds; `cargo machete -p torrust-tracker-metrics` reports no unused deps |
100+
| T1 | DONE | Define `DurationSinceUnixEpoch` in `packages/clock/src/lib.rs` | `pub type DurationSinceUnixEpoch = std::time::Duration;` |
101+
| T2 | DONE | Update `packages/clock/src/clock/mod.rs` and `packages/clock/src/conv/mod.rs` to use the local definition | Replace `use torrust_tracker_primitives::DurationSinceUnixEpoch` with local import |
102+
| T3 | DONE | Remove `torrust-tracker-primitives` dep from `packages/clock/Cargo.toml` | Dep entry removed; workspace build still passes |
103+
| T4 | DONE | Update all 80+ workspace files to import `DurationSinceUnixEpoch` from `torrust_tracker_clock` instead of `torrust_tracker_primitives` | Use M1 grep to find the full file list; one-line change per file |
104+
| T5 | DONE | Run `cargo build --workspace` and `cargo test --workspace` | Clean build and all tests pass |
105+
| T6 | DONE | Run `linter all` | Exit code `0` |
106+
| T7 | DONE | Update EPIC #1669 extraction ordering table: note that `torrust-tracker-clock` has no `torrust-tracker-primitives` dep | `torrust-tracker-clock` row: `torrust-tracker-primitives` dep removed |
107+
| T8 | DONE | Update `torrust-tracker-metrics`: replace import of `DurationSinceUnixEpoch` from `torrust_tracker_primitives` with `torrust_tracker_clock`; remove `torrust-tracker-primitives` dep from its `Cargo.toml` if no longer needed | `cargo build -p torrust-tracker-metrics` succeeds; `cargo machete -p torrust-tracker-metrics` reports no unused deps |
108108

109109
## Progress Tracking
110110

@@ -114,8 +114,8 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`.
114114
- [x] Spec reviewed and approved by user/maintainer
115115
- [x] GitHub issue created and issue number added to this spec
116116
- [x] Spec moved to `docs/issues/open/` with issue number prefix
117-
- [ ] Implementation completed
118-
- [ ] Automatic verification completed (`linter all`, `cargo test --workspace`)
117+
- [x] Implementation completed
118+
- [x] Automatic verification completed (`linter all`, `cargo test --workspace`)
119119
- [ ] Manual verification scenarios executed and recorded
120120
- [ ] Acceptance criteria reviewed after implementation and updated with evidence
121121
- [ ] EPIC #1669 Active Subissues table updated to `DONE`
@@ -129,6 +129,10 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`.
129129
- 2026-05-18 00:00 UTC - josecelano - Spec updated to target current crate name
130130
`torrust-tracker-clock` (Option A: proceed without SI-09 prerequisite). SI-09 prerequisite
131131
removed; type will land as `torrust_tracker_clock::DurationSinceUnixEpoch`.
132+
- 2026-05-18 18:30 UTC - josecelano - Implementation complete. All 77 workspace files
133+
updated. `torrust-tracker-clock` no longer depends on `torrust-tracker-primitives`.
134+
`torrust-tracker-metrics` now imports from `torrust-tracker-clock`.
135+
`cargo build --workspace`, `cargo test --workspace`, and `linter all` all pass.
132136

133137
## Acceptance Criteria
134138

@@ -157,8 +161,8 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`.
157161

158162
Status values: `TODO`, `IN_PROGRESS`, `DONE`, `FAILED`, `BLOCKED`.
159163

160-
| ID | Scenario | Command / Steps | Expected Result | Status | Evidence |
161-
| --- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------- | ------ | -------- |
162-
| M1 | No workspace import from `torrust_tracker_primitives` for this type | `grep -r "torrust_tracker_primitives::DurationSinceUnixEpoch" . --include="*.rs"` | Zero matches | TODO | |
163-
| M2 | `torrust-tracker-clock` dep list is clean | `grep "torrust-tracker-primitives" packages/clock/Cargo.toml` | No output | TODO | |
164-
| M3 | `torrust-tracker-clock` exports `DurationSinceUnixEpoch` | `grep "DurationSinceUnixEpoch" packages/clock/src/lib.rs` | `pub type DurationSinceUnixEpoch` found | TODO | |
164+
| ID | Scenario | Command / Steps | Expected Result | Status | Evidence |
165+
| --- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------- | ------ | --------------------------------------------------------------------------------------- |
166+
| M1 | No workspace import from `torrust_tracker_primitives` for this type | `grep -r "torrust_tracker_primitives::DurationSinceUnixEpoch" . --include="*.rs"` | Zero matches | DONE | Zero matches (only `primitives/` defines the type; no consumer imports it from there) |
167+
| M2 | `torrust-tracker-clock` dep list is clean | `grep "torrust-tracker-primitives" packages/clock/Cargo.toml` | No output | DONE | No output confirmed |
168+
| M3 | `torrust-tracker-clock` exports `DurationSinceUnixEpoch` | `grep "DurationSinceUnixEpoch" packages/clock/src/lib.rs` | `pub type DurationSinceUnixEpoch` found | DONE | `pub type DurationSinceUnixEpoch = std::time::Duration;` in `packages/clock/src/lib.rs` |

0 commit comments

Comments
 (0)