Skip to content

Commit 3bc8148

Browse files
committed
refactor: [#1541] rename DatabasePersistentTorrentRepository to DatabaseDownloadsMetricRepository
1 parent 46df7eb commit 3bc8148

File tree

14 files changed

+40
-40
lines changed

14 files changed

+40
-40
lines changed

packages/axum-http-tracker-server/src/v1/handlers/announce.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ mod tests {
120120
use bittorrent_tracker_core::authentication::service::AuthenticationService;
121121
use bittorrent_tracker_core::databases::setup::initialize_database;
122122
use bittorrent_tracker_core::torrent::repository::in_memory::InMemoryTorrentRepository;
123-
use bittorrent_tracker_core::torrent::repository::persisted::DatabasePersistentTorrentRepository;
123+
use bittorrent_tracker_core::torrent::repository::persisted::DatabaseDownloadsMetricRepository;
124124
use bittorrent_tracker_core::whitelist::authorization::WhitelistAuthorization;
125125
use bittorrent_tracker_core::whitelist::repository::in_memory::InMemoryWhitelist;
126126
use torrust_tracker_configuration::Configuration;
@@ -156,7 +156,7 @@ mod tests {
156156
let in_memory_key_repository = Arc::new(InMemoryKeyRepository::default());
157157
let authentication_service = Arc::new(AuthenticationService::new(&config.core, &in_memory_key_repository));
158158
let in_memory_torrent_repository = Arc::new(InMemoryTorrentRepository::default());
159-
let db_torrent_repository = Arc::new(DatabasePersistentTorrentRepository::new(&database));
159+
let db_torrent_repository = Arc::new(DatabaseDownloadsMetricRepository::new(&database));
160160
let announce_handler = Arc::new(AnnounceHandler::new(
161161
&config.core,
162162
&whitelist_authorization,

packages/http-tracker-core/benches/helpers/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use bittorrent_tracker_core::authentication::key::repository::in_memory::InMemor
1515
use bittorrent_tracker_core::authentication::service::AuthenticationService;
1616
use bittorrent_tracker_core::databases::setup::initialize_database;
1717
use bittorrent_tracker_core::torrent::repository::in_memory::InMemoryTorrentRepository;
18-
use bittorrent_tracker_core::torrent::repository::persisted::DatabasePersistentTorrentRepository;
18+
use bittorrent_tracker_core::torrent::repository::persisted::DatabaseDownloadsMetricRepository;
1919
use bittorrent_tracker_core::whitelist::authorization::WhitelistAuthorization;
2020
use bittorrent_tracker_core::whitelist::repository::in_memory::InMemoryWhitelist;
2121
use futures::future::BoxFuture;
@@ -45,7 +45,7 @@ pub fn initialize_core_tracker_services_with_config(config: &Configuration) -> (
4545
let core_config = Arc::new(config.core.clone());
4646
let database = initialize_database(&config.core);
4747
let in_memory_torrent_repository = Arc::new(InMemoryTorrentRepository::default());
48-
let db_torrent_repository = Arc::new(DatabasePersistentTorrentRepository::new(&database));
48+
let db_torrent_repository = Arc::new(DatabaseDownloadsMetricRepository::new(&database));
4949
let in_memory_whitelist = Arc::new(InMemoryWhitelist::default());
5050
let whitelist_authorization = Arc::new(WhitelistAuthorization::new(&config.core, &in_memory_whitelist.clone()));
5151
let in_memory_key_repository = Arc::new(InMemoryKeyRepository::default());

packages/http-tracker-core/src/services/announce.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ mod tests {
213213
use bittorrent_tracker_core::authentication::service::AuthenticationService;
214214
use bittorrent_tracker_core::databases::setup::initialize_database;
215215
use bittorrent_tracker_core::torrent::repository::in_memory::InMemoryTorrentRepository;
216-
use bittorrent_tracker_core::torrent::repository::persisted::DatabasePersistentTorrentRepository;
216+
use bittorrent_tracker_core::torrent::repository::persisted::DatabaseDownloadsMetricRepository;
217217
use bittorrent_tracker_core::whitelist::authorization::WhitelistAuthorization;
218218
use bittorrent_tracker_core::whitelist::repository::in_memory::InMemoryWhitelist;
219219
use torrust_tracker_configuration::{Configuration, Core};
@@ -239,7 +239,7 @@ mod tests {
239239
let core_config = Arc::new(config.core.clone());
240240
let database = initialize_database(&config.core);
241241
let in_memory_torrent_repository = Arc::new(InMemoryTorrentRepository::default());
242-
let db_torrent_repository = Arc::new(DatabasePersistentTorrentRepository::new(&database));
242+
let db_torrent_repository = Arc::new(DatabaseDownloadsMetricRepository::new(&database));
243243
let in_memory_whitelist = Arc::new(InMemoryWhitelist::default());
244244
let whitelist_authorization = Arc::new(WhitelistAuthorization::new(&config.core, &in_memory_whitelist.clone()));
245245
let in_memory_key_repository = Arc::new(InMemoryKeyRepository::default());

packages/http-tracker-core/src/services/scrape.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ mod tests {
177177
use bittorrent_tracker_core::databases::setup::initialize_database;
178178
use bittorrent_tracker_core::scrape_handler::ScrapeHandler;
179179
use bittorrent_tracker_core::torrent::repository::in_memory::InMemoryTorrentRepository;
180-
use bittorrent_tracker_core::torrent::repository::persisted::DatabasePersistentTorrentRepository;
180+
use bittorrent_tracker_core::torrent::repository::persisted::DatabaseDownloadsMetricRepository;
181181
use bittorrent_tracker_core::whitelist::authorization::WhitelistAuthorization;
182182
use bittorrent_tracker_core::whitelist::repository::in_memory::InMemoryWhitelist;
183183
use futures::future::BoxFuture;
@@ -200,7 +200,7 @@ mod tests {
200200
let in_memory_whitelist = Arc::new(InMemoryWhitelist::default());
201201
let whitelist_authorization = Arc::new(WhitelistAuthorization::new(&config.core, &in_memory_whitelist.clone()));
202202
let in_memory_torrent_repository = Arc::new(InMemoryTorrentRepository::default());
203-
let db_torrent_repository = Arc::new(DatabasePersistentTorrentRepository::new(&database));
203+
let db_torrent_repository = Arc::new(DatabaseDownloadsMetricRepository::new(&database));
204204
let in_memory_key_repository = Arc::new(InMemoryKeyRepository::default());
205205
let authentication_service = Arc::new(AuthenticationService::new(&config.core, &in_memory_key_repository));
206206

packages/tracker-core/src/announce_handler.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ use torrust_tracker_primitives::core::AnnounceData;
9999
use torrust_tracker_primitives::peer;
100100

101101
use super::torrent::repository::in_memory::InMemoryTorrentRepository;
102-
use super::torrent::repository::persisted::DatabasePersistentTorrentRepository;
102+
use super::torrent::repository::persisted::DatabaseDownloadsMetricRepository;
103103
use crate::error::AnnounceError;
104104
use crate::whitelist::authorization::WhitelistAuthorization;
105105

@@ -115,7 +115,7 @@ pub struct AnnounceHandler {
115115
in_memory_torrent_repository: Arc<InMemoryTorrentRepository>,
116116

117117
/// Repository for persistent torrent data (database).
118-
db_torrent_repository: Arc<DatabasePersistentTorrentRepository>,
118+
db_torrent_repository: Arc<DatabaseDownloadsMetricRepository>,
119119
}
120120

121121
impl AnnounceHandler {
@@ -125,7 +125,7 @@ impl AnnounceHandler {
125125
config: &Core,
126126
whitelist_authorization: &Arc<WhitelistAuthorization>,
127127
in_memory_torrent_repository: &Arc<InMemoryTorrentRepository>,
128-
db_torrent_repository: &Arc<DatabasePersistentTorrentRepository>,
128+
db_torrent_repository: &Arc<DatabaseDownloadsMetricRepository>,
129129
) -> Self {
130130
Self {
131131
whitelist_authorization: whitelist_authorization.clone(),

packages/tracker-core/src/container.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::databases::Database;
1313
use crate::scrape_handler::ScrapeHandler;
1414
use crate::torrent::manager::TorrentsManager;
1515
use crate::torrent::repository::in_memory::InMemoryTorrentRepository;
16-
use crate::torrent::repository::persisted::DatabasePersistentTorrentRepository;
16+
use crate::torrent::repository::persisted::DatabaseDownloadsMetricRepository;
1717
use crate::whitelist::authorization::WhitelistAuthorization;
1818
use crate::whitelist::manager::WhitelistManager;
1919
use crate::whitelist::repository::in_memory::InMemoryWhitelist;
@@ -31,7 +31,7 @@ pub struct TrackerCoreContainer {
3131
pub whitelist_authorization: Arc<whitelist::authorization::WhitelistAuthorization>,
3232
pub whitelist_manager: Arc<WhitelistManager>,
3333
pub in_memory_torrent_repository: Arc<InMemoryTorrentRepository>,
34-
pub db_torrent_repository: Arc<DatabasePersistentTorrentRepository>,
34+
pub db_torrent_repository: Arc<DatabaseDownloadsMetricRepository>,
3535
pub torrents_manager: Arc<TorrentsManager>,
3636
pub stats_repository: Arc<statistics::repository::Repository>,
3737
}
@@ -51,7 +51,7 @@ impl TrackerCoreContainer {
5151
&in_memory_key_repository.clone(),
5252
));
5353
let in_memory_torrent_repository = Arc::new(InMemoryTorrentRepository::new(torrent_repository_container.swarms.clone()));
54-
let db_torrent_repository = Arc::new(DatabasePersistentTorrentRepository::new(&database));
54+
let db_torrent_repository = Arc::new(DatabaseDownloadsMetricRepository::new(&database));
5555

5656
let torrents_manager = Arc::new(TorrentsManager::new(
5757
core_config,

packages/tracker-core/src/statistics/event/handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use torrust_tracker_torrent_repository::event::Event;
77

88
use crate::statistics::repository::Repository;
99
use crate::statistics::TRACKER_CORE_PERSISTENT_TORRENTS_DOWNLOADS_TOTAL;
10-
use crate::torrent::repository::persisted::DatabasePersistentTorrentRepository;
10+
use crate::torrent::repository::persisted::DatabaseDownloadsMetricRepository;
1111

1212
pub async fn handle_event(
1313
event: Event,
1414
stats_repository: &Arc<Repository>,
15-
db_torrent_repository: &Arc<DatabasePersistentTorrentRepository>,
15+
db_torrent_repository: &Arc<DatabaseDownloadsMetricRepository>,
1616
persistent_torrent_completed_stat: bool,
1717
now: DurationSinceUnixEpoch,
1818
) {

packages/tracker-core/src/statistics/event/listener.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ use torrust_tracker_torrent_repository::event::receiver::Receiver;
77

88
use super::handler::handle_event;
99
use crate::statistics::repository::Repository;
10-
use crate::torrent::repository::persisted::DatabasePersistentTorrentRepository;
10+
use crate::torrent::repository::persisted::DatabaseDownloadsMetricRepository;
1111
use crate::{CurrentClock, TRACKER_CORE_LOG_TARGET};
1212

1313
#[must_use]
1414
pub fn run_event_listener(
1515
receiver: Receiver,
1616
repository: &Arc<Repository>,
17-
db_torrent_repository: &Arc<DatabasePersistentTorrentRepository>,
17+
db_torrent_repository: &Arc<DatabaseDownloadsMetricRepository>,
1818
persistent_torrent_completed_stat: bool,
1919
) -> JoinHandle<()> {
2020
let stats_repository = repository.clone();
21-
let db_torrent_repository: Arc<DatabasePersistentTorrentRepository> = db_torrent_repository.clone();
21+
let db_torrent_repository: Arc<DatabaseDownloadsMetricRepository> = db_torrent_repository.clone();
2222

2323
tracing::info!(target: TRACKER_CORE_LOG_TARGET, "Starting torrent repository event listener");
2424

@@ -38,7 +38,7 @@ pub fn run_event_listener(
3838
async fn dispatch_events(
3939
mut receiver: Receiver,
4040
stats_repository: Arc<Repository>,
41-
db_torrent_repository: Arc<DatabasePersistentTorrentRepository>,
41+
db_torrent_repository: Arc<DatabaseDownloadsMetricRepository>,
4242
persistent_torrent_completed_stat: bool,
4343
) {
4444
let shutdown_signal = tokio::signal::ctrl_c();

packages/tracker-core/src/statistics/persisted_metrics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use torrust_tracker_primitives::DurationSinceUnixEpoch;
88
use super::repository::Repository;
99
use super::TRACKER_CORE_PERSISTENT_TORRENTS_DOWNLOADS_TOTAL;
1010
use crate::databases;
11-
use crate::torrent::repository::persisted::DatabasePersistentTorrentRepository;
11+
use crate::torrent::repository::persisted::DatabaseDownloadsMetricRepository;
1212

1313
/// Loads persisted metrics from the database and sets them in the stats repository.
1414
///
@@ -18,7 +18,7 @@ use crate::torrent::repository::persisted::DatabasePersistentTorrentRepository;
1818
/// metric collection fails to set the initial metric values.
1919
pub async fn load_persisted_metrics(
2020
stats_repository: &Arc<Repository>,
21-
db_torrent_repository: &Arc<DatabasePersistentTorrentRepository>,
21+
db_torrent_repository: &Arc<DatabaseDownloadsMetricRepository>,
2222
now: DurationSinceUnixEpoch,
2323
) -> Result<(), Error> {
2424
if let Some(downloads) = db_torrent_repository.load_global_number_of_downloads()? {

packages/tracker-core/src/test_helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(crate) mod tests {
2020
use crate::databases::setup::initialize_database;
2121
use crate::scrape_handler::ScrapeHandler;
2222
use crate::torrent::repository::in_memory::InMemoryTorrentRepository;
23-
use crate::torrent::repository::persisted::DatabasePersistentTorrentRepository;
23+
use crate::torrent::repository::persisted::DatabaseDownloadsMetricRepository;
2424
use crate::whitelist::repository::in_memory::InMemoryWhitelist;
2525
use crate::whitelist::{self};
2626

@@ -137,7 +137,7 @@ pub(crate) mod tests {
137137
&in_memory_whitelist.clone(),
138138
));
139139
let in_memory_torrent_repository = Arc::new(InMemoryTorrentRepository::default());
140-
let db_torrent_repository = Arc::new(DatabasePersistentTorrentRepository::new(&database));
140+
let db_torrent_repository = Arc::new(DatabaseDownloadsMetricRepository::new(&database));
141141

142142
let announce_handler = Arc::new(AnnounceHandler::new(
143143
&config.core,

0 commit comments

Comments
 (0)