@@ -47,6 +47,47 @@ pub struct AppContainer {
47
47
}
48
48
49
49
impl AppContainer {
50
+ #[ instrument( skip( ) ) ]
51
+ pub fn initialize ( configuration : & Configuration ) -> AppContainer {
52
+ let core_config = Arc :: new ( configuration. core . clone ( ) ) ;
53
+
54
+ let tracker_core_container = TrackerCoreContainer :: initialize ( & core_config) ;
55
+
56
+ // HTTP stats
57
+ let ( http_stats_event_sender, http_stats_repository) =
58
+ bittorrent_http_tracker_core:: statistics:: setup:: factory ( configuration. core . tracker_usage_statistics ) ;
59
+ let http_stats_event_sender = Arc :: new ( http_stats_event_sender) ;
60
+ let http_stats_repository = Arc :: new ( http_stats_repository) ;
61
+
62
+ // UDP stats
63
+ let ( udp_stats_event_sender, udp_stats_repository) =
64
+ bittorrent_udp_tracker_core:: statistics:: setup:: factory ( configuration. core . tracker_usage_statistics ) ;
65
+ let udp_stats_event_sender = Arc :: new ( udp_stats_event_sender) ;
66
+ let udp_stats_repository = Arc :: new ( udp_stats_repository) ;
67
+
68
+ let ban_service = Arc :: new ( RwLock :: new ( BanService :: new ( MAX_CONNECTION_ID_ERRORS_PER_IP ) ) ) ;
69
+
70
+ AppContainer {
71
+ core_config,
72
+ database : tracker_core_container. database ,
73
+ announce_handler : tracker_core_container. announce_handler ,
74
+ scrape_handler : tracker_core_container. scrape_handler ,
75
+ keys_handler : tracker_core_container. keys_handler ,
76
+ authentication_service : tracker_core_container. authentication_service ,
77
+ in_memory_whitelist : tracker_core_container. in_memory_whitelist ,
78
+ whitelist_authorization : tracker_core_container. whitelist_authorization ,
79
+ whitelist_manager : tracker_core_container. whitelist_manager ,
80
+ in_memory_torrent_repository : tracker_core_container. in_memory_torrent_repository ,
81
+ db_torrent_repository : tracker_core_container. db_torrent_repository ,
82
+ torrents_manager : tracker_core_container. torrents_manager ,
83
+ ban_service,
84
+ http_stats_event_sender,
85
+ udp_stats_event_sender,
86
+ http_stats_repository,
87
+ udp_stats_repository,
88
+ }
89
+ }
90
+
50
91
#[ must_use]
51
92
pub fn http_tracker_container ( & self , http_tracker_config : & Arc < HttpTracker > ) -> HttpTrackerCoreContainer {
52
93
HttpTrackerCoreContainer {
@@ -91,45 +132,3 @@ impl AppContainer {
91
132
}
92
133
}
93
134
}
94
-
95
- /// It initializes the IoC Container.
96
- #[ instrument( skip( ) ) ]
97
- pub fn initialize_app_container ( configuration : & Configuration ) -> AppContainer {
98
- let core_config = Arc :: new ( configuration. core . clone ( ) ) ;
99
-
100
- let tracker_core_container = TrackerCoreContainer :: initialize ( & core_config) ;
101
-
102
- // HTTP stats
103
- let ( http_stats_event_sender, http_stats_repository) =
104
- bittorrent_http_tracker_core:: statistics:: setup:: factory ( configuration. core . tracker_usage_statistics ) ;
105
- let http_stats_event_sender = Arc :: new ( http_stats_event_sender) ;
106
- let http_stats_repository = Arc :: new ( http_stats_repository) ;
107
-
108
- // UDP stats
109
- let ( udp_stats_event_sender, udp_stats_repository) =
110
- bittorrent_udp_tracker_core:: statistics:: setup:: factory ( configuration. core . tracker_usage_statistics ) ;
111
- let udp_stats_event_sender = Arc :: new ( udp_stats_event_sender) ;
112
- let udp_stats_repository = Arc :: new ( udp_stats_repository) ;
113
-
114
- let ban_service = Arc :: new ( RwLock :: new ( BanService :: new ( MAX_CONNECTION_ID_ERRORS_PER_IP ) ) ) ;
115
-
116
- AppContainer {
117
- core_config,
118
- database : tracker_core_container. database ,
119
- announce_handler : tracker_core_container. announce_handler ,
120
- scrape_handler : tracker_core_container. scrape_handler ,
121
- keys_handler : tracker_core_container. keys_handler ,
122
- authentication_service : tracker_core_container. authentication_service ,
123
- in_memory_whitelist : tracker_core_container. in_memory_whitelist ,
124
- whitelist_authorization : tracker_core_container. whitelist_authorization ,
125
- whitelist_manager : tracker_core_container. whitelist_manager ,
126
- in_memory_torrent_repository : tracker_core_container. in_memory_torrent_repository ,
127
- db_torrent_repository : tracker_core_container. db_torrent_repository ,
128
- torrents_manager : tracker_core_container. torrents_manager ,
129
- ban_service,
130
- http_stats_event_sender,
131
- udp_stats_event_sender,
132
- http_stats_repository,
133
- udp_stats_repository,
134
- }
135
- }
0 commit comments