Skip to content

Commit b1df4e8

Browse files
committed
refactor: [#453] reorganize console mods
```console src/console/ ├── commands │   ├── mod.rs │   └── tracker_statistics_importer │   ├── app.rs │   └── mod.rs ├── cronjobs │   ├── mod.rs │   └── tracker_statistics_importer.rs └── mod.rs ``` - We will create a new command to seed the Index with random torrents. - This new strcuture is similar to what we have in the Tracker.
1 parent 17f2364 commit b1df4e8

File tree

8 files changed

+15
-9
lines changed

8 files changed

+15
-9
lines changed

src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub async fn run(configuration: Configuration, api_version: &Version) -> Running
159159

160160
// Start cronjob to import tracker torrent data and updating
161161
// seeders and leechers info.
162-
let tracker_statistics_importer_handle = console::tracker_statistics_importer::start(
162+
let tracker_statistics_importer_handle = console::cronjobs::tracker_statistics_importer::start(
163163
importer_port,
164164
importer_torrent_info_update_interval,
165165
&tracker_statistics_importer,
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Import Tracker Statistics command.
22
//!
3-
//! It imports the number of seeders and leechers for all torrent from the linked tracker.
3+
//! It imports the number of seeders and leechers for all torrents from the linked tracker.
44
//!
55
//! You can execute it with: `cargo run --bin import_tracker_statistics`
6-
use torrust_index::console::commands::import_tracker_statistics::run_importer;
6+
use torrust_index::console::commands::tracker_statistics_importer::app::run;
77

88
#[tokio::main]
99
async fn main() {
10-
run_importer().await;
10+
run().await;
1111
}

src/console/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub mod import_tracker_statistics;
1+
pub mod tracker_statistics_importer;

src/console/commands/import_tracker_statistics.rs renamed to src/console/commands/tracker_statistics_importer/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn print_usage() {
7575
/// # Panics
7676
///
7777
/// Panics if arguments cannot be parsed.
78-
pub async fn run_importer() {
78+
pub async fn run() {
7979
parse_args().expect("unable to parse command arguments");
8080
import().await;
8181
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod app;

src/console/cronjobs/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod tracker_statistics_importer;

src/console/tracker_statistics_importer.rs renamed to src/console/cronjobs/tracker_statistics_importer.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ struct ImporterState {
3333
pub torrent_info_update_interval: u64,
3434
}
3535

36+
/// # Panics
37+
///
38+
/// Will panic if it can't start the tracker statistics importer API
39+
#[must_use]
3640
pub fn start(
3741
importer_port: u16,
3842
torrent_info_update_interval: u64,
@@ -60,7 +64,7 @@ pub fn start(
6064

6165
let addr = format!("{IMPORTER_API_IP}:{importer_port}");
6266

63-
info!("Tracker statistics importer API server listening on http://{}", addr);
67+
info!("Tracker statistics importer API server listening on http://{}", addr); // # DevSkim: ignore DS137138
6468

6569
axum::Server::bind(&addr.parse().unwrap())
6670
.serve(app.into_make_service())
@@ -122,7 +126,7 @@ async fn heartbeat_handler(State(state): State<Arc<ImporterState>>) -> Json<Valu
122126
/// Send a heartbeat from the importer cronjob to the importer API.
123127
async fn send_heartbeat(importer_port: u16) -> Result<(), reqwest::Error> {
124128
let client = reqwest::Client::new();
125-
let url = format!("http://{IMPORTER_API_IP}:{importer_port}/heartbeat");
129+
let url = format!("http://{IMPORTER_API_IP}:{importer_port}/heartbeat"); // # DevSkim: ignore DS137138
126130

127131
client.post(url).send().await?;
128132

src/console/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pub mod commands;
2-
pub(crate) mod tracker_statistics_importer;
2+
pub mod cronjobs;

0 commit comments

Comments
 (0)