Skip to content

Commit

Permalink
fix(example): imports renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanpetterson committed Aug 30, 2023
1 parent 6d1156b commit 6c87627
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions examples/http.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
use anyhow::Result;
use axum::routing::post;
use axum::Router;
use timer_rs::Timer;
use timeware::Timer;
use tokio::signal;

#[tokio::main]
async fn main() -> Result<()> {
// Initialize tracing.
tracing_subscriber::fmt::init();

let timer = Timer::new(|| {
tracing::info!("task was executed");
None
})
.with_graceful_shutdown(signal::ctrl_c());
let timer = Timer::new().with_graceful_shutdown(signal::ctrl_c());

let scheduler = timer.scheduler();
tokio::spawn(async move {
Expand Down Expand Up @@ -41,7 +37,7 @@ async fn main() -> Result<()> {
mod http {
use axum::{extract::State, response::IntoResponse, Json};
use chrono::NaiveDateTime;
use timer_rs::Scheduler;
use timeware::Scheduler;

#[derive(Clone)]
pub struct AppState {
Expand All @@ -59,6 +55,10 @@ mod http {
Json(payload): Json<Payload>,
) -> impl IntoResponse {
tracing::info!("received scheduling for {}", payload.date);
state.scheduler.schedule(payload.date).await.unwrap();
state
.scheduler
.schedule(payload.date, || tracing::info!("task was executed"))
.await
.unwrap();
}
}

0 comments on commit 6c87627

Please sign in to comment.