@@ -21,7 +21,7 @@ use bittorrent_tracker_core::whitelist;
21
21
use torrust_tracker_configuration:: Core ;
22
22
use torrust_tracker_primitives:: core:: AnnounceData ;
23
23
24
- use crate :: packages :: http_tracker_core ;
24
+ use crate :: statistics ;
25
25
26
26
/// The HTTP tracker `announce` service.
27
27
///
@@ -46,7 +46,7 @@ pub async fn handle_announce(
46
46
announce_handler : & Arc < AnnounceHandler > ,
47
47
authentication_service : & Arc < AuthenticationService > ,
48
48
whitelist_authorization : & Arc < whitelist:: authorization:: WhitelistAuthorization > ,
49
- opt_http_stats_event_sender : & Arc < Option < Box < dyn http_tracker_core :: statistics:: event:: sender:: Sender > > > ,
49
+ opt_http_stats_event_sender : & Arc < Option < Box < dyn statistics:: event:: sender:: Sender > > > ,
50
50
announce_request : & Announce ,
51
51
client_ip_sources : & ClientIpSources ,
52
52
maybe_key : Option < Key > ,
@@ -95,12 +95,12 @@ pub async fn handle_announce(
95
95
match original_peer_ip {
96
96
IpAddr :: V4 ( _) => {
97
97
http_stats_event_sender
98
- . send_event ( http_tracker_core :: statistics:: event:: Event :: Tcp4Announce )
98
+ . send_event ( statistics:: event:: Event :: Tcp4Announce )
99
99
. await ;
100
100
}
101
101
IpAddr :: V6 ( _) => {
102
102
http_stats_event_sender
103
- . send_event ( http_tracker_core :: statistics:: event:: Event :: Tcp6Announce )
103
+ . send_event ( statistics:: event:: Event :: Tcp6Announce )
104
104
. await ;
105
105
}
106
106
}
@@ -138,7 +138,7 @@ mod tests {
138
138
}
139
139
140
140
struct CoreHttpTrackerServices {
141
- pub http_stats_event_sender : Arc < Option < Box < dyn http_tracker_core :: statistics:: event:: sender:: Sender > > > ,
141
+ pub http_stats_event_sender : Arc < Option < Box < dyn statistics:: event:: sender:: Sender > > > ,
142
142
}
143
143
144
144
fn initialize_core_tracker_services ( ) -> ( CoreTrackerServices , CoreHttpTrackerServices ) {
@@ -163,8 +163,7 @@ mod tests {
163
163
) ) ;
164
164
165
165
// HTTP stats
166
- let ( http_stats_event_sender, http_stats_repository) =
167
- http_tracker_core:: statistics:: setup:: factory ( config. core . tracker_usage_statistics ) ;
166
+ let ( http_stats_event_sender, http_stats_repository) = statistics:: setup:: factory ( config. core . tracker_usage_statistics ) ;
168
167
let http_stats_event_sender = Arc :: new ( http_stats_event_sender) ;
169
168
let _http_stats_repository = Arc :: new ( http_stats_repository) ;
170
169
@@ -229,13 +228,13 @@ mod tests {
229
228
use mockall:: mock;
230
229
use tokio:: sync:: mpsc:: error:: SendError ;
231
230
232
- use crate :: packages :: http_tracker_core ;
233
- use crate :: servers :: http :: test_helpers :: tests:: sample_info_hash;
231
+ use crate :: statistics ;
232
+ use crate :: tests:: sample_info_hash;
234
233
235
234
mock ! {
236
235
HttpStatsEventSender { }
237
- impl http_tracker_core :: statistics:: event:: sender:: Sender for HttpStatsEventSender {
238
- fn send_event( & self , event: http_tracker_core :: statistics:: event:: Event ) -> BoxFuture <' static , Option <Result <( ) , SendError <http_tracker_core :: statistics:: event:: Event > > > > ;
236
+ impl statistics:: event:: sender:: Sender for HttpStatsEventSender {
237
+ fn send_event( & self , event: statistics:: event:: Event ) -> BoxFuture <' static , Option <Result <( ) , SendError <statistics:: event:: Event > > > > ;
239
238
}
240
239
}
241
240
@@ -252,12 +251,12 @@ mod tests {
252
251
use torrust_tracker_test_helpers:: configuration;
253
252
254
253
use super :: { sample_peer_using_ipv4, sample_peer_using_ipv6} ;
255
- use crate :: packages:: http_tracker_core;
256
- use crate :: packages:: http_tracker_core:: services:: announce:: handle_announce;
257
- use crate :: packages:: http_tracker_core:: services:: announce:: tests:: {
254
+ use crate :: services:: announce:: handle_announce;
255
+ use crate :: services:: announce:: tests:: {
258
256
initialize_core_tracker_services, initialize_core_tracker_services_with_config, sample_announce_request_for_peer,
259
257
sample_peer, MockHttpStatsEventSender ,
260
258
} ;
259
+ use crate :: statistics;
261
260
262
261
#[ tokio:: test]
263
262
async fn it_should_return_the_announce_data ( ) {
@@ -298,10 +297,10 @@ mod tests {
298
297
let mut http_stats_event_sender_mock = MockHttpStatsEventSender :: new ( ) ;
299
298
http_stats_event_sender_mock
300
299
. expect_send_event ( )
301
- . with ( eq ( http_tracker_core :: statistics:: event:: Event :: Tcp4Announce ) )
300
+ . with ( eq ( statistics:: event:: Event :: Tcp4Announce ) )
302
301
. times ( 1 )
303
302
. returning ( |_| Box :: pin ( future:: ready ( Some ( Ok ( ( ) ) ) ) ) ) ;
304
- let http_stats_event_sender: Arc < Option < Box < dyn http_tracker_core :: statistics:: event:: sender:: Sender > > > =
303
+ let http_stats_event_sender: Arc < Option < Box < dyn statistics:: event:: sender:: Sender > > > =
305
304
Arc :: new ( Some ( Box :: new ( http_stats_event_sender_mock) ) ) ;
306
305
307
306
let ( core_tracker_services, mut core_http_tracker_services) = initialize_core_tracker_services ( ) ;
@@ -349,10 +348,10 @@ mod tests {
349
348
let mut http_stats_event_sender_mock = MockHttpStatsEventSender :: new ( ) ;
350
349
http_stats_event_sender_mock
351
350
. expect_send_event ( )
352
- . with ( eq ( http_tracker_core :: statistics:: event:: Event :: Tcp4Announce ) )
351
+ . with ( eq ( statistics:: event:: Event :: Tcp4Announce ) )
353
352
. times ( 1 )
354
353
. returning ( |_| Box :: pin ( future:: ready ( Some ( Ok ( ( ) ) ) ) ) ) ;
355
- let http_stats_event_sender: Arc < Option < Box < dyn http_tracker_core :: statistics:: event:: sender:: Sender > > > =
354
+ let http_stats_event_sender: Arc < Option < Box < dyn statistics:: event:: sender:: Sender > > > =
356
355
Arc :: new ( Some ( Box :: new ( http_stats_event_sender_mock) ) ) ;
357
356
358
357
let ( core_tracker_services, mut core_http_tracker_services) =
@@ -383,10 +382,10 @@ mod tests {
383
382
let mut http_stats_event_sender_mock = MockHttpStatsEventSender :: new ( ) ;
384
383
http_stats_event_sender_mock
385
384
. expect_send_event ( )
386
- . with ( eq ( http_tracker_core :: statistics:: event:: Event :: Tcp6Announce ) )
385
+ . with ( eq ( statistics:: event:: Event :: Tcp6Announce ) )
387
386
. times ( 1 )
388
387
. returning ( |_| Box :: pin ( future:: ready ( Some ( Ok ( ( ) ) ) ) ) ) ;
389
- let http_stats_event_sender: Arc < Option < Box < dyn http_tracker_core :: statistics:: event:: sender:: Sender > > > =
388
+ let http_stats_event_sender: Arc < Option < Box < dyn statistics:: event:: sender:: Sender > > > =
390
389
Arc :: new ( Some ( Box :: new ( http_stats_event_sender_mock) ) ) ;
391
390
392
391
let ( core_tracker_services, mut core_http_tracker_services) = initialize_core_tracker_services ( ) ;
0 commit comments