Skip to content

Overhaul core Tracker: create dependency containers for UDP tracker, HTTP tracker and Tracker API #1217

@josecelano

Description

@josecelano

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:

  • UdpTrackerContainer
  • HttpTrackerContainer
  • TrackerApiContainer

cc @da2ce7

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions