Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul core Tracker: remove complexity (type_complexity) #1215

Closed
Tracked by #1181
josecelano opened this issue Jan 28, 2025 · 0 comments · Fixed by #1216
Closed
Tracked by #1181

Overhaul core Tracker: remove complexity (type_complexity) #1215

josecelano opened this issue Jan 28, 2025 · 0 comments · Fixed by #1216
Assignees
Labels
- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat

Comments

@josecelano
Copy link
Member

josecelano commented Jan 28, 2025

Parent issue: #1181

After removing the core Tracker we don't need anymore functions like these:

/// Initialize the tracker dependencies.
#[allow(clippy::type_complexity)]
#[must_use]
pub fn initialize_tracker_dependencies(
    config: &Configuration,
) -> (
    Arc<Box<dyn Database>>,
    Arc<InMemoryWhitelist>,
    Arc<whitelist::authorization::WhitelistAuthorization>,
    Arc<AuthenticationService>,
    Arc<InMemoryTorrentRepository>,
    Arc<DatabasePersistentTorrentRepository>,
    Arc<TorrentsManager>,
) {
    let database = initialize_database(config);
    let in_memory_whitelist = Arc::new(InMemoryWhitelist::default());
    let whitelist_authorization = Arc::new(whitelist::authorization::WhitelistAuthorization::new(
        &config.core,
        &in_memory_whitelist.clone(),
    ));
    let db_key_repository = Arc::new(DatabaseKeyRepository::new(&database));
    let in_memory_key_repository = Arc::new(InMemoryKeyRepository::default());
    let authentication_service = Arc::new(service::AuthenticationService::new(&config.core, &in_memory_key_repository));
    let _keys_handler = Arc::new(KeysHandler::new(
        &db_key_repository.clone(),
        &in_memory_key_repository.clone(),
    ));
    let in_memory_torrent_repository = Arc::new(InMemoryTorrentRepository::default());
    let db_torrent_repository = Arc::new(DatabasePersistentTorrentRepository::new(&database));
    let torrents_manager = Arc::new(TorrentsManager::new(
        &config.core,
        &in_memory_torrent_repository,
        &db_torrent_repository,
    ));

    (
        database,
        in_memory_whitelist,
        whitelist_authorization,
        authentication_service,
        in_memory_torrent_repository,
        db_torrent_repository,
        torrents_manager,
    )
}

We only need to instantiate the dependencies for the services we actually need. That kind of functions were used to instantiate the tracker with all its dependencies.

@josecelano josecelano added - Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat labels Jan 28, 2025
@josecelano josecelano self-assigned this Jan 28, 2025
@josecelano josecelano mentioned this issue Jan 28, 2025
26 tasks
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 28, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 28, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 28, 2025
@josecelano josecelano changed the title Overhaul core Tracker: remove complexity Overhaul core Tracker: remove complexity (type_complexity) Jan 28, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 28, 2025
josecelano added a commit that referenced this issue Jan 28, 2025
8f02fb9 refactor: [#1215] instantiate only needed services (Jose Celano)

Pull request description:

  Overhaul core Tracker: remove complexity.

ACKs for top commit:
  josecelano:
    ACK 8f02fb9

Tree-SHA512: a2878294aaa7ce9f33c7a945c4aa737035e5c030d9610632cc2fd4e1819284680c619d87180356ec71c28ccc1b71969efae958f9120a3aab426f7aa853c08680
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant