torrust_tracker/core/services/
mod.rs

1//! Tracker domain services. Core and statistics services.
2//!
3//! There are two types of service:
4//!
5//! - [Core tracker services](crate::core::services::torrent): related to the tracker main functionalities like getting info about torrents.
6//! - [Services for statistics](crate::core::services::statistics): related to tracker metrics. Aggregate data about the tracker server.
7pub mod statistics;
8pub mod torrent;
9
10use std::sync::Arc;
11
12use torrust_tracker_configuration::Configuration;
13
14use crate::core::Tracker;
15
16/// It returns a new tracker building its dependencies.
17///
18/// # Panics
19///
20/// Will panic if tracker cannot be instantiated.
21#[must_use]
22pub fn tracker_factory(config: &Configuration) -> Tracker {
23    // Initialize statistics
24    let (stats_event_sender, stats_repository) = statistics::setup::factory(config.core.tracker_usage_statistics);
25
26    // Initialize Torrust tracker
27    match Tracker::new(&Arc::new(config).core, stats_event_sender, stats_repository) {
28        Ok(tracker) => tracker,
29        Err(error) => {
30            panic!("{}", error)
31        }
32    }
33}