Skip to content

feat(primitives): create torrust-net-primitives and move ServiceBinding (#1797)#1799

Merged
josecelano merged 6 commits into
torrust:developfrom
josecelano:1669-05-create-torrust-net-primitives-and-move-service-binding
May 20, 2026
Merged

feat(primitives): create torrust-net-primitives and move ServiceBinding (#1797)#1799
josecelano merged 6 commits into
torrust:developfrom
josecelano:1669-05-create-torrust-net-primitives-and-move-service-binding

Conversation

@josecelano
Copy link
Copy Markdown
Member

Moves ServiceBinding out of torrust-tracker-primitives into a new dedicated
torrust-net-primitives crate. torrust-server-lib now depends on
torrust-net-primitives instead of torrust-tracker-primitives, breaking an
unnecessary coupling between a generic server utility and tracker-specific types.

Motivation

The coupling analysis (F-04 in EPIC #1669) found that torrust-server-lib
depended on torrust-tracker-primitives solely to import ServiceBinding — a
struct representing a network address binding. torrust-server-lib has no
tracker-specific concerns; pulling in the entire torrust-tracker-* primitives
crate for one generic networking type is wasteful and semantically misleading.

ServiceBinding is a generic concept reusable across the Torrust organisation,
not just the tracker. A dedicated torrust-net-primitives crate makes the type
available to any Torrust project without a torrust-tracker-* dependency.

Changes

New crate

  • packages/net-primitives/ — new torrust-net-primitives crate (publish = true)
    • src/service_binding.rsServiceBinding and Protocol (moved from packages/primitives/)
    • src/lib.rs — exports pub mod service_binding
    • README.md

Updated workspace root

  • Cargo.toml — added packages/net-primitives to [workspace] members
  • Cargo.lock — updated

Updated packages (Cargo.toml + import paths)

  • packages/primitives/ — removed service_binding module definition; added
    #[deprecated] re-export from torrust_net_primitives for external crates.io
    consumer backwards compatibility (same pattern as DurationSinceUnixEpoch and
    AnnouncePolicy)
  • packages/server-lib/ — replaced torrust-tracker-primitives dep with
    torrust-net-primitives (ServiceBinding was its only use)
  • packages/axum-health-check-api-server/, packages/axum-http-tracker-server/,
    packages/axum-rest-tracker-api-server/, packages/http-tracker-core/,
    packages/tracker-client/, packages/udp-tracker-core/,
    packages/udp-tracker-server/ — added torrust-net-primitives dep; updated
    all import paths from torrust_tracker_primitives::service_binding to
    torrust_net_primitives::service_binding across ~45 source files

Docs

Validation

Check Result
cargo build --workspace ✅ clean
cargo test --workspace ✅ all pass
linter all ✅ exit code 0
cargo machete ✅ no unused deps
cargo +nightly fmt --check ✅ pass
cargo +nightly check --workspace --all-targets ✅ pass
cargo +nightly doc --no-deps --workspace ✅ pass
grep "torrust_tracker_primitives::.*ServiceBinding" --include="*.rs" -r . ✅ zero matches
grep "torrust-tracker-primitives" packages/server-lib/Cargo.toml ✅ zero matches

Closes #1797

Part of #1669 (SI-05)

…ng (torrust#1797)

Moves ServiceBinding out of torrust-tracker-primitives into a new dedicated
torrust-net-primitives crate. torrust-server-lib now depends on
torrust-net-primitives instead of torrust-tracker-primitives, breaking an
unnecessary coupling between a generic server utility and tracker-specific types.

Changes:
- Create packages/net-primitives/ with Cargo.toml, src/lib.rs, and README.md
- Add packages/net-primitives to workspace [members] in root Cargo.toml
- Move service_binding module to packages/net-primitives/src/
- Replace service_binding module in packages/primitives/src/ with a
  #[deprecated] re-export from torrust_net_primitives for backwards
  compatibility with external crates.io consumers
- Add torrust-net-primitives dep to packages/primitives/Cargo.toml
- Update packages/server-lib/Cargo.toml: replace torrust-tracker-primitives
  dep with torrust-net-primitives (ServiceBinding was its only use)
- Add torrust-net-primitives dep to all other packages importing ServiceBinding:
  axum-health-check-api-server, axum-http-tracker-server,
  axum-rest-tracker-api-server, http-tracker-core, tracker-client,
  udp-tracker-core, udp-tracker-server
- Update all workspace import paths from torrust_tracker_primitives::service_binding
  to torrust_net_primitives::service_binding across ~45 files

All acceptance criteria verified:
- cargo build --workspace: clean
- linter all: exit code 0
- pre-commit hook: pass

Part of torrust#1669 (SI-05)
Copilot AI review requested due to automatic review settings May 19, 2026 20:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extracts ServiceBinding (and Protocol) from torrust-tracker-primitives into a new dedicated torrust-net-primitives crate, breaking the unnecessary coupling between torrust-server-lib and tracker-specific primitives.

Changes:

  • New packages/net-primitives crate (publish = true) hosting service_binding module (moved from packages/primitives).
  • packages/primitives keeps a #[deprecated] re-export of service_binding for crates.io backwards compatibility.
  • All workspace consumers (server-lib, axum servers, http/udp tracker core/server, tracker-client) updated to import from torrust_net_primitives::service_binding; server-lib no longer depends on torrust-tracker-primitives.

Reviewed changes

Copilot reviewed 53 out of 54 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/net-primitives/{Cargo.toml,README.md,src/lib.rs,src/service_binding.rs} New crate scaffolding and moved module
packages/primitives/{Cargo.toml,src/lib.rs} Drop module, add #[deprecated] re-export, depend on net-primitives
packages/server-lib/{Cargo.toml,src/registar.rs,src/signals.rs} Swap dep and imports
packages/{axum-health-check-api-server,axum-http-tracker-server,axum-rest-tracker-api-server,http-tracker-core,udp-tracker-core,udp-tracker-server,tracker-client}/** Add dep and update imports
Cargo.toml, Cargo.lock Workspace members and lockfile updates
docs/issues/open/1797-*, docs/issues/open/1669-overhaul-packages/{EPIC.md,workspace-coupling-report.md} Spec promoted to open, EPIC updated, coupling report regenerated

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@josecelano josecelano self-assigned this May 19, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 54 out of 55 changed files in this pull request and generated no new comments.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 0% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.69%. Comparing base (ca97cce) to head (88de3d5).

Files with missing lines Patch % Lines
.../dev-tools/analysis/workspace-coupling/src/main.rs 0.00% 29 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1799      +/-   ##
===========================================
+ Coverage    77.64%   77.69%   +0.04%     
===========================================
  Files          379      379              
  Lines        28602    28607       +5     
  Branches     28602    28607       +5     
===========================================
+ Hits         22209    22226      +17     
+ Misses        6080     6072       -8     
+ Partials       313      309       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Without this feature, derive_more::Display was unavailable when compiling
bittorrent-tracker-client in isolation. It previously worked only because
of accidental transitive feature unification via
primitives -> configuration, which was removed in torrust#1795.

Fixes E2E CI failure on PR torrust#1799.
@josecelano
Copy link
Copy Markdown
Member Author

ACK 88de3d5

@josecelano josecelano merged commit 6e212ec into torrust:develop May 20, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create torrust-net-primitives and move ServiceBinding from torrust-tracker-primitives

2 participants