-
Notifications
You must be signed in to change notification settings - Fork 48
Labels
- Developer -Torrust Improvement ExperienceTorrust Improvement ExperienceCode Cleanup / RefactoringTidying and Making NeatTidying and Making Neat
Description
Parent issue: #1181
I'm working on a big refactor. I'm extracting responsibilities from the core tracker. The Tracker
is acting like a kind of IoC container because it instantiates many services. Since I'm extracting those services from the tracker we need a container for them. I'm going to add a IoC container so this code:
#[tokio::main]
async fn main() {
let (config, tracker, udp_ban_service, stats_event_sender, stats_repository) = bootstrap::app::setup();
let jobs = app::start(&config, tracker, udp_ban_service, stats_event_sender, stats_repository).await;
// handle the signals
tokio::select! {
_ = tokio::signal::ctrl_c() => {
tracing::info!("Torrust shutting down ...");
// Await for all jobs to shutdown
futures::future::join_all(jobs).await;
tracing::info!("Torrust successfully shutdown.");
}
}
}
can be replaced with something like:
#[tokio::main]
async fn main() {
let app_container: AppContanier = bootstrap::app::setup();
let jobs = app::start(&config, app_container).await;
// handle the signals
tokio::select! {
_ = tokio::signal::ctrl_c() => {
tracing::info!("Torrust shutting down ...");
// Await for all jobs to shutdown
futures::future::join_all(jobs).await;
tracing::info!("Torrust successfully shutdown.");
}
}
}
In the Index we called AppData but I think I will call it AppContainer
.
There is a crate shaku to handle compilation time dependencies but I don't want to introduce complex dependencies for now. And some dependencies are defined at runtime (database, ..).
Metadata
Metadata
Assignees
Labels
- Developer -Torrust Improvement ExperienceTorrust Improvement ExperienceCode Cleanup / RefactoringTidying and Making NeatTidying and Making Neat