diff --git a/src/bootstrap/app.rs b/src/bootstrap/app.rs index 71684a7e3..8a084dc7f 100644 --- a/src/bootstrap/app.rs +++ b/src/bootstrap/app.rs @@ -27,13 +27,15 @@ use crate::core::authentication::handler::KeysHandler; use crate::core::authentication::key::repository::in_memory::InMemoryKeyRepository; use crate::core::authentication::key::repository::persisted::DatabaseKeyRepository; use crate::core::authentication::service; +use crate::core::databases::setup::initialize_database; use crate::core::scrape_handler::ScrapeHandler; -use crate::core::services::{initialize_database, initialize_whitelist_manager, statistics}; +use crate::core::statistics; use crate::core::torrent::manager::TorrentsManager; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; use crate::core::torrent::repository::persisted::DatabasePersistentTorrentRepository; use crate::core::whitelist::authorization::WhitelistAuthorization; use crate::core::whitelist::repository::in_memory::InMemoryWhitelist; +use crate::core::whitelist::setup::initialize_whitelist_manager; use crate::servers::udp::server::banning::BanService; use crate::servers::udp::server::launcher::MAX_CONNECTION_ID_ERRORS_PER_IP; use crate::shared::crypto::ephemeral_instance_keys; diff --git a/src/core/announce_handler.rs b/src/core/announce_handler.rs index 1a5f84d47..816663bf6 100644 --- a/src/core/announce_handler.rs +++ b/src/core/announce_handler.rs @@ -414,7 +414,7 @@ mod tests { use crate::core::announce_handler::tests::the_announce_handler::peer_ip; use crate::core::announce_handler::{AnnounceHandler, PeersWanted}; use crate::core::core_tests::{sample_info_hash, sample_peer}; - use crate::core::services::initialize_database; + use crate::core::databases::setup::initialize_database; use crate::core::torrent::manager::TorrentsManager; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; use crate::core::torrent::repository::persisted::DatabasePersistentTorrentRepository; diff --git a/src/core/authentication/handler.rs b/src/core/authentication/handler.rs index 5ec9a11b4..d6477a948 100644 --- a/src/core/authentication/handler.rs +++ b/src/core/authentication/handler.rs @@ -246,7 +246,7 @@ mod tests { use crate::core::authentication::handler::KeysHandler; use crate::core::authentication::key::repository::in_memory::InMemoryKeyRepository; use crate::core::authentication::key::repository::persisted::DatabaseKeyRepository; - use crate::core::services::initialize_database; + use crate::core::databases::setup::initialize_database; fn instantiate_keys_handler() -> KeysHandler { let config = configuration::ephemeral_private(); diff --git a/src/core/authentication/mod.rs b/src/core/authentication/mod.rs index 0180b3a1e..eddcc1ae7 100644 --- a/src/core/authentication/mod.rs +++ b/src/core/authentication/mod.rs @@ -27,7 +27,7 @@ mod tests { use crate::core::authentication::key::repository::persisted::DatabaseKeyRepository; use crate::core::authentication::service; use crate::core::authentication::service::AuthenticationService; - use crate::core::services::initialize_database; + use crate::core::databases::setup::initialize_database; fn instantiate_keys_manager_and_authentication() -> (Arc, Arc) { let config = configuration::ephemeral_private(); diff --git a/src/core/core_tests.rs b/src/core/core_tests.rs index 45949bae2..35d5fb9b7 100644 --- a/src/core/core_tests.rs +++ b/src/core/core_tests.rs @@ -9,8 +9,8 @@ use torrust_tracker_primitives::peer::Peer; use torrust_tracker_primitives::DurationSinceUnixEpoch; use super::announce_handler::AnnounceHandler; +use super::databases::setup::initialize_database; use super::scrape_handler::ScrapeHandler; -use super::services::initialize_database; use super::torrent::repository::in_memory::InMemoryTorrentRepository; use super::torrent::repository::persisted::DatabasePersistentTorrentRepository; use super::whitelist::repository::in_memory::InMemoryWhitelist; diff --git a/src/core/databases/mod.rs b/src/core/databases/mod.rs index e0b1b4f1b..dec6b799d 100644 --- a/src/core/databases/mod.rs +++ b/src/core/databases/mod.rs @@ -46,6 +46,7 @@ pub mod driver; pub mod error; pub mod mysql; +pub mod setup; pub mod sqlite; use std::marker::PhantomData; diff --git a/src/core/databases/setup.rs b/src/core/databases/setup.rs new file mode 100644 index 000000000..728913e05 --- /dev/null +++ b/src/core/databases/setup.rs @@ -0,0 +1,20 @@ +use std::sync::Arc; + +use torrust_tracker_configuration::v2_0_0::database; +use torrust_tracker_configuration::Configuration; + +use super::driver::{self, Driver}; +use super::Database; + +/// # Panics +/// +/// Will panic if database cannot be initialized. +#[must_use] +pub fn initialize_database(config: &Configuration) -> Arc> { + let driver = match config.core.database.driver { + database::Driver::Sqlite3 => Driver::Sqlite3, + database::Driver::MySQL => Driver::MySQL, + }; + + Arc::new(driver::build(&driver, &config.core.database.path).expect("Database driver build failed.")) +} diff --git a/src/core/mod.rs b/src/core/mod.rs index 7d5e7d4d6..125a67b5a 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -344,10 +344,10 @@ //! //! # Services //! -//! Services are domain services on top of the core tracker. Right now there are two types of service: +//! Services are domain services on top of the core tracker domain. Right now there are two types of service: //! -//! - For statistics -//! - For torrents +//! - For statistics: [`crate::core::statistics::services`] +//! - For torrents: [`crate::core::torrent::services`] //! //! Services usually format the data inside the tracker to make it easier to consume by other parts. //! They also decouple the internal data structure, used by the tracker, from the way we deliver that data to the consumers. @@ -356,8 +356,6 @@ //! //! Services can include extra features like pagination, for example. //! -//! Refer to [`services`] module for more information about services. -//! //! # Authentication //! //! One of the core `Tracker` responsibilities is to create and keep authentication keys. Auth keys are used by HTTP trackers @@ -444,7 +442,6 @@ pub mod authentication; pub mod databases; pub mod error; pub mod scrape_handler; -pub mod services; pub mod statistics; pub mod torrent; pub mod whitelist; diff --git a/src/core/services/mod.rs b/src/core/services/mod.rs deleted file mode 100644 index f2ee79993..000000000 --- a/src/core/services/mod.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Tracker domain services. Core and statistics services. -//! -//! There are two types of service: -//! -//! - [Core tracker services](crate::core::services::torrent): related to the tracker main functionalities like getting info about torrents. -//! - [Services for statistics](crate::core::services::statistics): related to tracker metrics. Aggregate data about the tracker server. -pub mod statistics; -pub mod torrent; - -use std::sync::Arc; - -use databases::driver::Driver; -use torrust_tracker_configuration::v2_0_0::database; -use torrust_tracker_configuration::Configuration; - -use super::databases::{self, Database}; -use super::whitelist::manager::WhitelistManager; -use super::whitelist::repository::in_memory::InMemoryWhitelist; -use super::whitelist::repository::persisted::DatabaseWhitelist; - -/// # Panics -/// -/// Will panic if database cannot be initialized. -#[must_use] -pub fn initialize_database(config: &Configuration) -> Arc> { - let driver = match config.core.database.driver { - database::Driver::Sqlite3 => Driver::Sqlite3, - database::Driver::MySQL => Driver::MySQL, - }; - - Arc::new(databases::driver::build(&driver, &config.core.database.path).expect("Database driver build failed.")) -} - -#[must_use] -pub fn initialize_whitelist_manager( - database: Arc>, - in_memory_whitelist: Arc, -) -> Arc { - let database_whitelist = Arc::new(DatabaseWhitelist::new(database)); - Arc::new(WhitelistManager::new(database_whitelist, in_memory_whitelist)) -} diff --git a/src/core/statistics/mod.rs b/src/core/statistics/mod.rs index 49a82bea9..2ffbc0c8f 100644 --- a/src/core/statistics/mod.rs +++ b/src/core/statistics/mod.rs @@ -28,3 +28,5 @@ pub mod event; pub mod keeper; pub mod metrics; pub mod repository; +pub mod services; +pub mod setup; diff --git a/src/core/services/statistics/mod.rs b/src/core/statistics/services.rs similarity index 95% rename from src/core/services/statistics/mod.rs rename to src/core/statistics/services.rs index 79bc5f268..337731aea 100644 --- a/src/core/services/statistics/mod.rs +++ b/src/core/statistics/services.rs @@ -2,7 +2,7 @@ //! //! It includes: //! -//! - A [`factory`](crate::core::services::statistics::setup::factory) function to build the structs needed to collect the tracker metrics. +//! - A [`factory`](crate::core::statistics::setup::factory) function to build the structs needed to collect the tracker metrics. //! - A [`get_metrics`] service to get the tracker [`metrics`](crate::core::statistics::metrics::Metrics). //! //! Tracker metrics are collected using a Publisher-Subscribe pattern. @@ -36,8 +36,6 @@ //! // ... //! } //! ``` -pub mod setup; - use std::sync::Arc; use tokio::sync::RwLock; @@ -117,9 +115,9 @@ mod tests { use torrust_tracker_primitives::torrent_metrics::TorrentsMetrics; use torrust_tracker_test_helpers::configuration; - use crate::core::services::statistics::{self, get_metrics, TrackerMetrics}; + use crate::core::statistics::services::{get_metrics, TrackerMetrics}; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; - use crate::core::{self}; + use crate::core::{self, statistics}; use crate::servers::udp::server::banning::BanService; use crate::servers::udp::server::launcher::MAX_CONNECTION_ID_ERRORS_PER_IP; diff --git a/src/core/services/statistics/setup.rs b/src/core/statistics/setup.rs similarity index 100% rename from src/core/services/statistics/setup.rs rename to src/core/statistics/setup.rs diff --git a/src/core/torrent/mod.rs b/src/core/torrent/mod.rs index 95a5ff1eb..2aa19130e 100644 --- a/src/core/torrent/mod.rs +++ b/src/core/torrent/mod.rs @@ -27,6 +27,7 @@ //! pub mod manager; pub mod repository; +pub mod services; use torrust_tracker_torrent_repository::TorrentsSkipMapMutexStd; diff --git a/src/core/services/torrent.rs b/src/core/torrent/services.rs similarity index 97% rename from src/core/services/torrent.rs rename to src/core/torrent/services.rs index dac93ce16..5a4810412 100644 --- a/src/core/services/torrent.rs +++ b/src/core/torrent/services.rs @@ -135,9 +135,9 @@ mod tests { use bittorrent_primitives::info_hash::InfoHash; - use crate::core::services::torrent::tests::sample_peer; - use crate::core::services::torrent::{get_torrent_info, Info}; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; + use crate::core::torrent::services::tests::sample_peer; + use crate::core::torrent::services::{get_torrent_info, Info}; #[tokio::test] async fn should_return_none_if_the_tracker_does_not_have_the_torrent() { @@ -184,9 +184,9 @@ mod tests { use bittorrent_primitives::info_hash::InfoHash; - use crate::core::services::torrent::tests::sample_peer; - use crate::core::services::torrent::{get_torrents_page, BasicInfo, Pagination}; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; + use crate::core::torrent::services::tests::sample_peer; + use crate::core::torrent::services::{get_torrents_page, BasicInfo, Pagination}; #[tokio::test] async fn should_return_an_empty_result_if_the_tracker_does_not_have_any_torrent() { diff --git a/src/core/whitelist/mod.rs b/src/core/whitelist/mod.rs index c23740111..1f5f87626 100644 --- a/src/core/whitelist/mod.rs +++ b/src/core/whitelist/mod.rs @@ -1,6 +1,7 @@ pub mod authorization; pub mod manager; pub mod repository; +pub mod setup; pub mod whitelist_tests; #[cfg(test)] diff --git a/src/core/whitelist/setup.rs b/src/core/whitelist/setup.rs new file mode 100644 index 000000000..bdd35737c --- /dev/null +++ b/src/core/whitelist/setup.rs @@ -0,0 +1,15 @@ +use std::sync::Arc; + +use super::manager::WhitelistManager; +use super::repository::in_memory::InMemoryWhitelist; +use super::repository::persisted::DatabaseWhitelist; +use crate::core::databases::Database; + +#[must_use] +pub fn initialize_whitelist_manager( + database: Arc>, + in_memory_whitelist: Arc, +) -> Arc { + let database_whitelist = Arc::new(DatabaseWhitelist::new(database)); + Arc::new(WhitelistManager::new(database_whitelist, in_memory_whitelist)) +} diff --git a/src/core/whitelist/whitelist_tests.rs b/src/core/whitelist/whitelist_tests.rs index aa9c5ca14..38c2bbde3 100644 --- a/src/core/whitelist/whitelist_tests.rs +++ b/src/core/whitelist/whitelist_tests.rs @@ -5,7 +5,8 @@ use torrust_tracker_configuration::Configuration; use super::authorization::WhitelistAuthorization; use super::manager::WhitelistManager; use super::repository::in_memory::InMemoryWhitelist; -use crate::core::services::{initialize_database, initialize_whitelist_manager}; +use crate::core::databases::setup::initialize_database; +use crate::core::whitelist::setup::initialize_whitelist_manager; #[must_use] pub fn initialize_whitelist_services(config: &Configuration) -> (Arc, Arc) { diff --git a/src/servers/apis/v1/context/stats/handlers.rs b/src/servers/apis/v1/context/stats/handlers.rs index da87696fc..b8e7abd87 100644 --- a/src/servers/apis/v1/context/stats/handlers.rs +++ b/src/servers/apis/v1/context/stats/handlers.rs @@ -9,8 +9,8 @@ use serde::Deserialize; use tokio::sync::RwLock; use super::responses::{metrics_response, stats_response}; -use crate::core::services::statistics::get_metrics; use crate::core::statistics::repository::Repository; +use crate::core::statistics::services::get_metrics; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; use crate::servers::udp::server::banning::BanService; diff --git a/src/servers/apis/v1/context/stats/resources.rs b/src/servers/apis/v1/context/stats/resources.rs index c6a526a7d..97ece22fc 100644 --- a/src/servers/apis/v1/context/stats/resources.rs +++ b/src/servers/apis/v1/context/stats/resources.rs @@ -2,7 +2,7 @@ //! API context. use serde::{Deserialize, Serialize}; -use crate::core::services::statistics::TrackerMetrics; +use crate::core::statistics::services::TrackerMetrics; /// It contains all the statistics generated by the tracker. #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] @@ -121,8 +121,8 @@ mod tests { use torrust_tracker_primitives::torrent_metrics::TorrentsMetrics; use super::Stats; - use crate::core::services::statistics::TrackerMetrics; use crate::core::statistics::metrics::Metrics; + use crate::core::statistics::services::TrackerMetrics; #[test] fn stats_resource_should_be_converted_from_tracker_metrics() { diff --git a/src/servers/apis/v1/context/stats/responses.rs b/src/servers/apis/v1/context/stats/responses.rs index a67b5328a..6fda43f8c 100644 --- a/src/servers/apis/v1/context/stats/responses.rs +++ b/src/servers/apis/v1/context/stats/responses.rs @@ -3,7 +3,7 @@ use axum::response::{IntoResponse, Json, Response}; use super::resources::Stats; -use crate::core::services::statistics::TrackerMetrics; +use crate::core::statistics::services::TrackerMetrics; /// `200` response that contains the [`Stats`] resource as json. #[must_use] diff --git a/src/servers/apis/v1/context/torrent/handlers.rs b/src/servers/apis/v1/context/torrent/handlers.rs index 8fe20ab80..0ec90441d 100644 --- a/src/servers/apis/v1/context/torrent/handlers.rs +++ b/src/servers/apis/v1/context/torrent/handlers.rs @@ -13,8 +13,8 @@ use thiserror::Error; use torrust_tracker_primitives::pagination::Pagination; use super::responses::{torrent_info_response, torrent_list_response, torrent_not_known_response}; -use crate::core::services::torrent::{get_torrent_info, get_torrents, get_torrents_page}; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; +use crate::core::torrent::services::{get_torrent_info, get_torrents, get_torrents_page}; use crate::servers::apis::v1::responses::invalid_info_hash_param_response; use crate::servers::apis::InfoHashParam; diff --git a/src/servers/apis/v1/context/torrent/resources/torrent.rs b/src/servers/apis/v1/context/torrent/resources/torrent.rs index 237470d88..c90a2a05f 100644 --- a/src/servers/apis/v1/context/torrent/resources/torrent.rs +++ b/src/servers/apis/v1/context/torrent/resources/torrent.rs @@ -6,7 +6,7 @@ //! the JSON response. use serde::{Deserialize, Serialize}; -use crate::core::services::torrent::{BasicInfo, Info}; +use crate::core::torrent::services::{BasicInfo, Info}; /// `Torrent` API resource. #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] @@ -102,7 +102,7 @@ mod tests { use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch}; use super::Torrent; - use crate::core::services::torrent::{BasicInfo, Info}; + use crate::core::torrent::services::{BasicInfo, Info}; use crate::servers::apis::v1::context::torrent::resources::peer::Peer; use crate::servers::apis::v1::context::torrent::resources::torrent::ListItem; diff --git a/src/servers/apis/v1/context/torrent/responses.rs b/src/servers/apis/v1/context/torrent/responses.rs index 5daceaf94..5174c9abe 100644 --- a/src/servers/apis/v1/context/torrent/responses.rs +++ b/src/servers/apis/v1/context/torrent/responses.rs @@ -4,7 +4,7 @@ use axum::response::{IntoResponse, Json, Response}; use serde_json::json; use super::resources::torrent::{ListItem, Torrent}; -use crate::core::services::torrent::{BasicInfo, Info}; +use crate::core::torrent::services::{BasicInfo, Info}; /// `200` response that contains an array of /// [`ListItem`] diff --git a/src/servers/http/v1/handlers/announce.rs b/src/servers/http/v1/handlers/announce.rs index d6c850327..544d706fa 100644 --- a/src/servers/http/v1/handlers/announce.rs +++ b/src/servers/http/v1/handlers/announce.rs @@ -257,7 +257,8 @@ mod tests { use crate::core::authentication::key::repository::in_memory::InMemoryKeyRepository; use crate::core::authentication::service::AuthenticationService; use crate::core::core_tests::sample_info_hash; - use crate::core::services::{initialize_database, statistics}; + use crate::core::databases::setup::initialize_database; + use crate::core::statistics; use crate::core::statistics::event::sender::Sender; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; use crate::core::torrent::repository::persisted::DatabasePersistentTorrentRepository; diff --git a/src/servers/http/v1/handlers/scrape.rs b/src/servers/http/v1/handlers/scrape.rs index a197263e8..35c5b1409 100644 --- a/src/servers/http/v1/handlers/scrape.rs +++ b/src/servers/http/v1/handlers/scrape.rs @@ -177,7 +177,7 @@ mod tests { use crate::core::authentication::key::repository::in_memory::InMemoryKeyRepository; use crate::core::authentication::service::AuthenticationService; use crate::core::scrape_handler::ScrapeHandler; - use crate::core::services::statistics; + use crate::core::statistics; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; use crate::core::whitelist::authorization::WhitelistAuthorization; use crate::core::whitelist::repository::in_memory::InMemoryWhitelist; diff --git a/src/servers/http/v1/services/announce.rs b/src/servers/http/v1/services/announce.rs index e96face6a..ee682559e 100644 --- a/src/servers/http/v1/services/announce.rs +++ b/src/servers/http/v1/services/announce.rs @@ -65,7 +65,8 @@ mod tests { use torrust_tracker_test_helpers::configuration; use crate::core::announce_handler::AnnounceHandler; - use crate::core::services::{initialize_database, statistics}; + use crate::core::databases::setup::initialize_database; + use crate::core::statistics; use crate::core::statistics::event::sender::Sender; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; use crate::core::torrent::repository::persisted::DatabasePersistentTorrentRepository; @@ -137,7 +138,7 @@ mod tests { use super::{sample_peer_using_ipv4, sample_peer_using_ipv6}; use crate::core::announce_handler::{AnnounceHandler, PeersWanted}; use crate::core::core_tests::sample_info_hash; - use crate::core::services::initialize_database; + use crate::core::databases::setup::initialize_database; use crate::core::statistics; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; use crate::core::torrent::repository::persisted::DatabasePersistentTorrentRepository; diff --git a/src/servers/http/v1/services/scrape.rs b/src/servers/http/v1/services/scrape.rs index 7e65b9442..b5a858b83 100644 --- a/src/servers/http/v1/services/scrape.rs +++ b/src/servers/http/v1/services/scrape.rs @@ -82,8 +82,8 @@ mod tests { use crate::core::announce_handler::AnnounceHandler; use crate::core::core_tests::sample_info_hash; + use crate::core::databases::setup::initialize_database; use crate::core::scrape_handler::ScrapeHandler; - use crate::core::services::initialize_database; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; use crate::core::torrent::repository::persisted::DatabasePersistentTorrentRepository; use crate::core::whitelist::authorization::WhitelistAuthorization; @@ -153,7 +153,7 @@ mod tests { #[tokio::test] async fn it_should_return_the_scrape_data_for_a_torrent() { - let (stats_event_sender, _stats_repository) = crate::core::services::statistics::setup::factory(false); + let (stats_event_sender, _stats_repository) = crate::core::statistics::setup::factory(false); let stats_event_sender = Arc::new(stats_event_sender); let (announce_handler, scrape_handler) = initialize_announce_and_scrape_handlers_for_public_tracker(); @@ -236,7 +236,7 @@ mod tests { #[tokio::test] async fn it_should_always_return_the_zeroed_scrape_data_for_a_torrent() { - let (stats_event_sender, _stats_repository) = crate::core::services::statistics::setup::factory(false); + let (stats_event_sender, _stats_repository) = crate::core::statistics::setup::factory(false); let stats_event_sender = Arc::new(stats_event_sender); let (announce_handler, _scrape_handler) = initialize_announce_and_scrape_handlers_for_public_tracker(); diff --git a/src/servers/udp/handlers.rs b/src/servers/udp/handlers.rs index 992f27a44..90c32771f 100644 --- a/src/servers/udp/handlers.rs +++ b/src/servers/udp/handlers.rs @@ -475,14 +475,14 @@ mod tests { use super::gen_remote_fingerprint; use crate::core::announce_handler::AnnounceHandler; + use crate::core::databases::setup::initialize_database; use crate::core::scrape_handler::ScrapeHandler; - use crate::core::services::{initialize_database, statistics}; use crate::core::statistics::event::sender::Sender; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; use crate::core::torrent::repository::persisted::DatabasePersistentTorrentRepository; - use crate::core::whitelist; use crate::core::whitelist::authorization::WhitelistAuthorization; use crate::core::whitelist::repository::in_memory::InMemoryWhitelist; + use crate::core::{statistics, whitelist}; use crate::CurrentClock; struct CoreTrackerServices { @@ -656,7 +656,7 @@ mod tests { #[tokio::test] async fn a_connect_response_should_contain_the_same_transaction_id_as_the_connect_request() { - let (stats_event_sender, _stats_repository) = crate::core::services::statistics::setup::factory(false); + let (stats_event_sender, _stats_repository) = crate::core::statistics::setup::factory(false); let stats_event_sender = Arc::new(stats_event_sender); let request = ConnectRequest { @@ -676,7 +676,7 @@ mod tests { #[tokio::test] async fn a_connect_response_should_contain_a_new_connection_id() { - let (stats_event_sender, _stats_repository) = crate::core::services::statistics::setup::factory(false); + let (stats_event_sender, _stats_repository) = crate::core::statistics::setup::factory(false); let stats_event_sender = Arc::new(stats_event_sender); let request = ConnectRequest { @@ -696,7 +696,7 @@ mod tests { #[tokio::test] async fn a_connect_response_should_contain_a_new_connection_id_ipv6() { - let (stats_event_sender, _stats_repository) = crate::core::services::statistics::setup::factory(false); + let (stats_event_sender, _stats_repository) = crate::core::statistics::setup::factory(false); let stats_event_sender = Arc::new(stats_event_sender); let request = ConnectRequest { @@ -1001,7 +1001,7 @@ mod tests { announce_handler: Arc, whitelist_authorization: Arc, ) -> Response { - let (stats_event_sender, _stats_repository) = crate::core::services::statistics::setup::factory(false); + let (stats_event_sender, _stats_repository) = crate::core::statistics::setup::factory(false); let stats_event_sender = Arc::new(stats_event_sender); let remote_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(126, 0, 0, 1)), 8080); @@ -1306,7 +1306,7 @@ mod tests { announce_handler: Arc, whitelist_authorization: Arc, ) -> Response { - let (stats_event_sender, _stats_repository) = crate::core::services::statistics::setup::factory(false); + let (stats_event_sender, _stats_repository) = crate::core::statistics::setup::factory(false); let stats_event_sender = Arc::new(stats_event_sender); let client_ip_v4 = Ipv4Addr::new(126, 0, 0, 1); @@ -1393,7 +1393,7 @@ mod tests { use mockall::predicate::eq; use crate::core::announce_handler::AnnounceHandler; - use crate::core::services::initialize_database; + use crate::core::databases::setup::initialize_database; use crate::core::statistics; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; use crate::core::torrent::repository::persisted::DatabasePersistentTorrentRepository; @@ -1494,7 +1494,7 @@ mod tests { use super::{gen_remote_fingerprint, TorrentPeerBuilder}; use crate::core::scrape_handler::ScrapeHandler; - use crate::core::services::statistics; + use crate::core::statistics; use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository; use crate::servers::udp::connection_cookie::make; use crate::servers::udp::handlers::handle_scrape;