-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
74 additions
and
21 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
use rocket::fairing::AdHoc; | ||
|
||
pub(crate) fn stage() -> AdHoc { | ||
AdHoc::on_ignite("task stage", |rocket| async { | ||
AdHoc::on_ignite("api task stage", |rocket| async { | ||
rocket.mount("/", routes![]) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
pub(crate) mod resource_organization; | ||
use rocket::fairing::AdHoc; | ||
|
||
pub(crate) mod resource; | ||
pub(crate) mod schedule; | ||
|
||
pub(crate) fn stage() -> AdHoc { | ||
AdHoc::on_ignite("task stage", |rocket| async { | ||
rocket | ||
.attach(resource::stage()) | ||
.attach(schedule::stage()) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::time::Duration; | ||
|
||
use rocket::fairing::AdHoc; | ||
use tokio::sync::mpsc; | ||
use tokio::sync::mpsc::{Receiver, Sender}; | ||
|
||
async fn start_task(tx: Sender<i32>) { | ||
let secs = 60 * 60 * 24; | ||
let mut interval_timer = tokio::time::interval(Duration::new(secs, 0)); | ||
loop { | ||
interval_timer.tick().await; | ||
let sender = tx.clone(); | ||
tokio::spawn(async { | ||
do_resource_task(sender).await; | ||
}); // For async task | ||
} | ||
} | ||
|
||
async fn do_resource_task(tx: Sender<i32>) { | ||
println!("do_resource_task"); | ||
} | ||
|
||
pub(crate) struct StateSchedule { | ||
pub(crate) schedule_repeating_rx: Receiver<i32>, | ||
} | ||
|
||
|
||
pub fn stage() -> AdHoc { | ||
AdHoc::on_ignite("task schedule_repeating", |rocket| async { | ||
let (schedule_repeating_tx, schedule_repeating_rx) = mpsc::channel(16); | ||
tokio::spawn(async move { | ||
println!("schedule_repeating task start"); | ||
start_task(schedule_repeating_tx).await; | ||
println!("schedule_repeating task stop") | ||
}); | ||
rocket.manage(StateSchedule { schedule_repeating_rx }) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters