-
Notifications
You must be signed in to change notification settings - Fork 51
Overhaul core Tracker: create dependency containers for UDP tracker, HTTP tracker and Tracker API #1217
Copy link
Copy link
Labels
- Developer -Torrust Improvement ExperienceTorrust Improvement ExperienceCode Cleanup / RefactoringTidying and Making NeatTidying and Making Neat
Description
Parent issue: #1181
After refactoring the core Tracker (it was removed), all services are injected independently where they are needed.
This function signature is very common:
impl Launcher {
#[allow(clippy::too_many_arguments)]
#[instrument(skip(
self,
announce_handler,
scrape_handler,
authentication_service,
whitelist_authorization,
stats_event_sender,
tx_start,
rx_halt
))]
fn start(
&self,
config: Arc<Core>,
announce_handler: Arc<AnnounceHandler>,
scrape_handler: Arc<ScrapeHandler>,
authentication_service: Arc<AuthenticationService>,
whitelist_authorization: Arc<whitelist::authorization::WhitelistAuthorization>,
stats_event_sender: Arc<Option<Box<dyn statistics::event::sender::Sender>>>,
tx_start: Sender<Started>,
rx_halt: Receiver<Halted>,
) -> BoxFuture<'static, ()> {
// ...
}
}
Where announce_handler, scrape_handler, authentication_service, whitelist_authorization and stats_event_sender are the services needed by this function.
We could pass the AppContainer I have introduced in this core tracker overhaul:
pub struct AppContainer {
pub database: Arc<Box<dyn Database>>,
pub announce_handler: Arc<AnnounceHandler>,
pub scrape_handler: Arc<ScrapeHandler>,
pub keys_handler: Arc<KeysHandler>,
pub authentication_service: Arc<AuthenticationService>,
pub whitelist_authorization: Arc<whitelist::authorization::WhitelistAuthorization>,
pub ban_service: Arc<RwLock<BanService>>,
pub stats_event_sender: Arc<Option<Box<dyn Sender>>>,
pub stats_repository: Arc<Repository>,
pub whitelist_manager: Arc<WhitelistManager>,
pub in_memory_torrent_repository: Arc<InMemoryTorrentRepository>,
pub db_torrent_repository: Arc<DatabasePersistentTorrentRepository>,
pub torrents_manager: Arc<TorrentsManager>,
}However the main three application user's services (UDP tracker, HTTP tracker and Tracker API) don't use the same services. My proposal is to create specific containers for those services:
UdpTrackerContainerHttpTrackerContainerTrackerApiContainer
cc @da2ce7
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- Developer -Torrust Improvement ExperienceTorrust Improvement ExperienceCode Cleanup / RefactoringTidying and Making NeatTidying and Making Neat