Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub async fn start(config: &Configuration, app_container: &AppContainer) -> Vec<
udp_tracker::start_job(
udp_tracker_config,
app_container.tracker.clone(),
app_container.scrape_handler.clone(),
app_container.whitelist_authorization.clone(),
app_container.stats_event_sender.clone(),
app_container.ban_service.clone(),
Expand All @@ -99,6 +100,7 @@ pub async fn start(config: &Configuration, app_container: &AppContainer) -> Vec<
if let Some(job) = http_tracker::start_job(
http_tracker_config,
app_container.tracker.clone(),
app_container.scrape_handler.clone(),
app_container.authentication_service.clone(),
app_container.whitelist_authorization.clone(),
app_container.stats_event_sender.clone(),
Expand Down
5 changes: 4 additions & 1 deletion src/bootstrap/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ 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::scrape_handler::ScrapeHandler;
use crate::core::services::{initialize_database, initialize_tracker, initialize_whitelist_manager, statistics};
use crate::core::torrent::manager::TorrentsManager;
use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository;
Expand Down Expand Up @@ -116,14 +117,16 @@ pub fn initialize_app_container(configuration: &Configuration) -> AppContainer {

let tracker = Arc::new(initialize_tracker(
configuration,
&whitelist_authorization,
&in_memory_torrent_repository,
&db_torrent_repository,
));

let scrape_handler = Arc::new(ScrapeHandler::new(&whitelist_authorization, &in_memory_torrent_repository));

AppContainer {
database,
tracker,
scrape_handler,
keys_handler,
authentication_service,
whitelist_authorization,
Expand Down
21 changes: 18 additions & 3 deletions src/bootstrap/jobs/http_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use tracing::instrument;

use super::make_rust_tls;
use crate::core::authentication::service::AuthenticationService;
use crate::core::scrape_handler::ScrapeHandler;
use crate::core::statistics::event::sender::Sender;
use crate::core::{self, statistics, whitelist};
use crate::servers::http::server::{HttpServer, Launcher};
Expand All @@ -34,11 +35,20 @@ use crate::servers::registar::ServiceRegistrationForm;
/// # Panics
///
/// It would panic if the `config::HttpTracker` struct would contain inappropriate values.
///
#[instrument(skip(config, tracker, authentication_service, whitelist_authorization, stats_event_sender, form))]
#[allow(clippy::too_many_arguments)]
#[instrument(skip(
config,
tracker,
scrape_handler,
authentication_service,
whitelist_authorization,
stats_event_sender,
form
))]
pub async fn start_job(
config: &HttpTracker,
tracker: Arc<core::Tracker>,
scrape_handler: Arc<ScrapeHandler>,
authentication_service: Arc<AuthenticationService>,
whitelist_authorization: Arc<whitelist::authorization::Authorization>,
stats_event_sender: Arc<Option<Box<dyn Sender>>>,
Expand All @@ -57,6 +67,7 @@ pub async fn start_job(
socket,
tls,
tracker.clone(),
scrape_handler.clone(),
authentication_service.clone(),
whitelist_authorization.clone(),
stats_event_sender.clone(),
Expand All @@ -67,12 +78,14 @@ pub async fn start_job(
}
}

#[allow(clippy::too_many_arguments)]
#[allow(clippy::async_yields_async)]
#[instrument(skip(socket, tls, tracker, whitelist_authorization, stats_event_sender, form))]
#[instrument(skip(socket, tls, tracker, scrape_handler, whitelist_authorization, stats_event_sender, form))]
async fn start_v1(
socket: SocketAddr,
tls: Option<RustlsConfig>,
tracker: Arc<core::Tracker>,
scrape_handler: Arc<ScrapeHandler>,
authentication_service: Arc<AuthenticationService>,
whitelist_authorization: Arc<whitelist::authorization::Authorization>,
stats_event_sender: Arc<Option<Box<dyn statistics::event::sender::Sender>>>,
Expand All @@ -81,6 +94,7 @@ async fn start_v1(
let server = HttpServer::new(Launcher::new(socket, tls))
.start(
tracker,
scrape_handler,
authentication_service,
whitelist_authorization,
stats_event_sender,
Expand Down Expand Up @@ -128,6 +142,7 @@ mod tests {
start_job(
config,
app_container.tracker,
app_container.scrape_handler,
app_container.authentication_service,
app_container.whitelist_authorization,
app_container.stats_event_sender,
Expand Down
13 changes: 12 additions & 1 deletion src/bootstrap/jobs/udp_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use tokio::task::JoinHandle;
use torrust_tracker_configuration::UdpTracker;
use tracing::instrument;

use crate::core::scrape_handler::ScrapeHandler;
use crate::core::statistics::event::sender::Sender;
use crate::core::{self, whitelist};
use crate::servers::registar::ServiceRegistrationForm;
Expand All @@ -32,10 +33,19 @@ use crate::servers::udp::UDP_TRACKER_LOG_TARGET;
/// It will panic if the task did not finish successfully.
#[must_use]
#[allow(clippy::async_yields_async)]
#[instrument(skip(config, tracker, whitelist_authorization, stats_event_sender, ban_service, form))]
#[instrument(skip(
config,
tracker,
scrape_handler,
whitelist_authorization,
stats_event_sender,
ban_service,
form
))]
pub async fn start_job(
config: &UdpTracker,
tracker: Arc<core::Tracker>,
scrape_handler: Arc<ScrapeHandler>,
whitelist_authorization: Arc<whitelist::authorization::Authorization>,
stats_event_sender: Arc<Option<Box<dyn Sender>>>,
ban_service: Arc<RwLock<BanService>>,
Expand All @@ -47,6 +57,7 @@ pub async fn start_job(
let server = Server::new(Spawner::new(bind_to))
.start(
tracker,
scrape_handler,
whitelist_authorization,
stats_event_sender,
ban_service,
Expand Down
2 changes: 2 additions & 0 deletions src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use tokio::sync::RwLock;
use crate::core::authentication::handler::KeysHandler;
use crate::core::authentication::service::AuthenticationService;
use crate::core::databases::Database;
use crate::core::scrape_handler::ScrapeHandler;
use crate::core::statistics::event::sender::Sender;
use crate::core::statistics::repository::Repository;
use crate::core::torrent::manager::TorrentsManager;
Expand All @@ -17,6 +18,7 @@ use crate::servers::udp::server::banning::BanService;
pub struct AppContainer {
pub database: Arc<Box<dyn Database>>,
pub tracker: Arc<Tracker>,
pub scrape_handler: Arc<ScrapeHandler>,
pub keys_handler: Arc<KeysHandler>,
pub authentication_service: Arc<AuthenticationService>,
pub whitelist_authorization: Arc<whitelist::authorization::Authorization>,
Expand Down
Loading