Skip to content

Overhaul core Tracker: extract torrents context (part 1)#1202

Merged
josecelano merged 11 commits intotorrust:developfrom
josecelano:1201-overhaul-core-tracker-extract-torrents-context
Jan 23, 2025
Merged

Overhaul core Tracker: extract torrents context (part 1)#1202
josecelano merged 11 commits intotorrust:developfrom
josecelano:1201-overhaul-core-tracker-extract-torrents-context

Conversation

@josecelano
Copy link
Copy Markdown
Member

@josecelano josecelano commented Jan 23, 2025

Overhaul core Tracker: extract torrents context.

The core Tracker is getting smaller and smaller. This PR reduces the dependencies to:

pub struct Tracker {
    /// The tracker configuration.
    config: Core,

    /// The service to check is a torrent is whitelisted.
    pub whitelist_authorization: Arc<whitelist::authorization::Authorization>,

    /// The in-memory torrents repository.
    in_memory_torrent_repository: Arc<InMemoryTorrentRepository>,

    /// The persistent torrents repository.
    db_torrent_repository: Arc<DatabasePersistentTorrentRepository>,
}

I will open a new PR (part 2) to continue extracting the rest of methods that are not used directly in a announce or scrape requests.

@josecelano josecelano linked an issue Jan 23, 2025 that may be closed by this pull request
@josecelano josecelano added the Code Cleanup / Refactoring Tidying and Making Neat label Jan 23, 2025
@josecelano josecelano added the - Developer - Torrust Improvement Experience label Jan 23, 2025
@josecelano josecelano self-assigned this Jan 23, 2025
@josecelano josecelano requested a review from da2ce7 January 23, 2025 16:24
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 95.00000% with 22 lines in your changes missing coverage. Please review.

Project coverage is 78.03%. Comparing base (444987b) to head (612f729).
Report is 12 commits behind head on develop.

Files with missing lines Patch % Lines
src/core/torrent/manager.rs 57.14% 11 Missing and 1 partial ⚠️
src/core/torrent/repository/in_memory.rs 80.95% 8 Missing ⚠️
src/bootstrap/jobs/torrent_cleanup.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1202      +/-   ##
===========================================
+ Coverage    77.61%   78.03%   +0.42%     
===========================================
  Files          188      191       +3     
  Lines        12696    12999     +303     
  Branches     12696    12999     +303     
===========================================
+ Hits          9854    10144     +290     
- Misses        2678     2687       +9     
- Partials       164      168       +4     

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

@josecelano josecelano changed the title Overhaul core Tracker: extract torrents context Overhaul core Tracker: extract torrents context (part 1) Jan 23, 2025
@josecelano josecelano marked this pull request as ready for review January 23, 2025 18:39
@josecelano
Copy link
Copy Markdown
Member Author

ACK 612f729

@josecelano josecelano linked an issue Jan 23, 2025 that may be closed by this pull request
@josecelano josecelano mentioned this pull request Jan 23, 2025
26 tasks
@josecelano josecelano merged commit a4277a7 into torrust:develop Jan 23, 2025
josecelano added a commit that referenced this pull request Jan 24, 2025
046578d refactor: [#1203] use directly the InMemoryTorrentRepository (Jose Celano)
0f1b2fb refactor: [#1203] use InMemoryTorrentRepository directly in core tracker tests (Jose Celano)
2ac68f6 refactor: [#1203] move test (Jose Celano)
94673d6 refactor: [#1203] inline methods in core tracker (Jose Celano)

Pull request description:

  This is part 2 of the refactor initiated [here](#1202).

  The core `Tracker` after this refactor:

  ```rust
  pub struct Tracker {
      /// The tracker configuration.
      config: Core,

      /// The service to check is a torrent is whitelisted.
      whitelist_authorization: Arc<whitelist::authorization::Authorization>,

      /// The in-memory torrents repository.
      in_memory_torrent_repository: Arc<InMemoryTorrentRepository>,

      /// The persistent torrents repository.
      db_torrent_repository: Arc<DatabasePersistentTorrentRepository>,
  }
  ```

ACKs for top commit:
  josecelano:
    ACK 046578d

Tree-SHA512: db32af87815375ca570b81392c392dae0b602d12f54543c413d34f6a8dcb69f7e2f56a56e5d552a271d7fe2e4f751277d9f6e204caee297a2e3333f6a7b77e24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overhaul core Tracker: extract torrents context (part 1)

1 participant