Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: segregate command and query for announce request #792

Merged
merged 1 commit into from
Apr 15, 2024

Conversation

josecelano
Copy link
Member

@josecelano josecelano commented Apr 12, 2024

This changes the API of the torrent repository.

The method:

fn update_torrent_with_peer_and_get_stats(&self, info_hash: &InfoHash, peer: &peer::Peer) -> (bool, SwarmMetadata);

is replaced with two methods (command and query):

fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer);
fn get_swarm_metadata(&self, info_hash: &InfoHash) -> Option<SwarmMetadata>;

The performance is not affected. Bechmarking is still using both methods in order to simulate announce requests.

The interface is simpler (command/query segregation).

Copy link

codecov bot commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 98.85057% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 78.15%. Comparing base (b5fb03b) to head (aa4bfba).

Files Patch % Lines
src/core/mod.rs 96.29% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #792      +/-   ##
===========================================
- Coverage    78.16%   78.15%   -0.02%     
===========================================
  Files          159      159              
  Lines         8863     8857       -6     
===========================================
- Hits          6928     6922       -6     
  Misses        1935     1935              

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

@josecelano josecelano added Code Cleanup / Refactoring Tidying and Making Neat - Developer - Torrust Improvement Experience labels Apr 12, 2024
@josecelano josecelano added this to the v3.0.0 milestone Apr 12, 2024
@josecelano josecelano marked this pull request as draft April 12, 2024 19:49
@josecelano josecelano force-pushed the refactor-core-tracker-api branch from b928cb2 to dc78a81 Compare April 12, 2024 19:50
@josecelano josecelano marked this pull request as ready for review April 12, 2024 19:50
This changes the API of the torrent repository. The method:

```
fn update_torrent_with_peer_and_get_stats(&self, info_hash: &InfoHash, peer: &peer::Peer) -> (bool, SwarmMetadata);
```

is replaced with:

```
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer);
fn get_swarm_metadata(&self, info_hash: &InfoHash) -> Option<SwarmMetadata>;
```

The performance is not affected. Benchmaring is still using both methods
in order to simulate `announce` requests.

1. The interface is simpler (command/query segregation.
2. In the long-term:
    - Returning swarm metadata in the announce request could be
      optional. The announce request process would be faster if the
tracker does not have to mantain the swarm data. This is not likely to
happen becuase the scrape request needs this metadata.
    - New repository performance improvements could be implemented. This allow
      decoupling peer lists from swarm metadata. The repository
internally can have two data strcutures one for the peer list and
another for the swarm metatada. Both using different locks.
@josecelano
Copy link
Member Author

ACK aa4bfba

@josecelano josecelano merged commit 24b82f3 into torrust:develop Apr 15, 2024
17 checks passed
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.

1 participant