|
1 | 1 | use std::sync::Arc; |
2 | 2 |
|
3 | 3 | use tokio::sync::RwLock; |
4 | | -use torrust_tracker_configuration::{Core, HttpTracker, UdpTracker}; |
| 4 | +use torrust_tracker_configuration::{Core, HttpApi, HttpTracker, UdpTracker}; |
5 | 5 |
|
6 | 6 | use crate::core::announce_handler::AnnounceHandler; |
7 | 7 | use crate::core::authentication::handler::KeysHandler; |
@@ -83,3 +83,30 @@ impl HttpTrackerContainer { |
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
| 86 | + |
| 87 | +pub struct HttpApiContainer { |
| 88 | + pub core_config: Arc<Core>, |
| 89 | + pub http_api_config: Arc<HttpApi>, |
| 90 | + pub in_memory_torrent_repository: Arc<InMemoryTorrentRepository>, |
| 91 | + pub keys_handler: Arc<KeysHandler>, |
| 92 | + pub whitelist_manager: Arc<WhitelistManager>, |
| 93 | + pub ban_service: Arc<RwLock<BanService>>, |
| 94 | + pub stats_event_sender: Arc<Option<Box<dyn Sender>>>, |
| 95 | + pub stats_repository: Arc<Repository>, |
| 96 | +} |
| 97 | + |
| 98 | +impl HttpApiContainer { |
| 99 | + #[must_use] |
| 100 | + pub fn from_app_container(http_api_config: &Arc<HttpApi>, app_container: &Arc<AppContainer>) -> Self { |
| 101 | + Self { |
| 102 | + http_api_config: http_api_config.clone(), |
| 103 | + core_config: app_container.core_config.clone(), |
| 104 | + in_memory_torrent_repository: app_container.in_memory_torrent_repository.clone(), |
| 105 | + keys_handler: app_container.keys_handler.clone(), |
| 106 | + whitelist_manager: app_container.whitelist_manager.clone(), |
| 107 | + ban_service: app_container.ban_service.clone(), |
| 108 | + stats_event_sender: app_container.stats_event_sender.clone(), |
| 109 | + stats_repository: app_container.stats_repository.clone(), |
| 110 | + } |
| 111 | + } |
| 112 | +} |
0 commit comments