diff --git a/fang_examples/blocking/simple_cron_worker/Cargo.toml b/fang_examples/blocking/simple_cron_worker/Cargo.toml index eab4aa4..b29f1c7 100644 --- a/fang_examples/blocking/simple_cron_worker/Cargo.toml +++ b/fang_examples/blocking/simple_cron_worker/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "simple_worker" +name = "simple_cron_worker" version = "0.1.0" -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -10,4 +10,4 @@ fang = { path = "../../../" , features = ["blocking"]} dotenv = "0.15.0" env_logger = "0.9.0" log = "0.4.0" -diesel = "1.4.8" +diesel = { version = "2", features = ["postgres", "r2d2"] } diff --git a/fang_examples/blocking/simple_cron_worker/src/lib.rs b/fang_examples/blocking/simple_cron_worker/src/lib.rs index 709e3d7..ab44341 100644 --- a/fang_examples/blocking/simple_cron_worker/src/lib.rs +++ b/fang_examples/blocking/simple_cron_worker/src/lib.rs @@ -1,7 +1,7 @@ use fang::runnable::Runnable; use fang::serde::{Deserialize, Serialize}; use fang::typetag; -use fang::Error; +use fang::FangError; use fang::Queueable; use fang::Scheduled; @@ -11,7 +11,7 @@ pub struct MyCronTask {} #[typetag::serde] impl Runnable for MyCronTask { - fn run(&self, _queue: &dyn Queueable) -> Result<(), Error> { + fn run(&self, _queue: &dyn Queueable) -> Result<(), FangError> { log::info!("CRON !!!!!!!!!!!!!!!!!"); Ok(()) diff --git a/fang_examples/blocking/simple_cron_worker/src/main.rs b/fang_examples/blocking/simple_cron_worker/src/main.rs index a218c63..76380f0 100644 --- a/fang_examples/blocking/simple_cron_worker/src/main.rs +++ b/fang_examples/blocking/simple_cron_worker/src/main.rs @@ -5,7 +5,7 @@ use fang::Queue; use fang::Queueable; use fang::RetentionMode; use fang::WorkerPool; -use simple_worker::MyCronTask; +use simple_cron_worker::MyCronTask; use std::env; use std::thread::sleep; use std::time::Duration; diff --git a/fang_examples/blocking/simple_worker/Cargo.toml b/fang_examples/blocking/simple_worker/Cargo.toml index eab4aa4..2bd62b0 100644 --- a/fang_examples/blocking/simple_worker/Cargo.toml +++ b/fang_examples/blocking/simple_worker/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "simple_worker" version = "0.1.0" -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -10,4 +10,4 @@ fang = { path = "../../../" , features = ["blocking"]} dotenv = "0.15.0" env_logger = "0.9.0" log = "0.4.0" -diesel = "1.4.8" +diesel = { version = "2", features = ["postgres", "r2d2"] } diff --git a/fang_examples/blocking/simple_worker/src/lib.rs b/fang_examples/blocking/simple_worker/src/lib.rs index a018c5a..4129591 100644 --- a/fang_examples/blocking/simple_worker/src/lib.rs +++ b/fang_examples/blocking/simple_worker/src/lib.rs @@ -1,7 +1,7 @@ use fang::runnable::Runnable; use fang::serde::{Deserialize, Serialize}; use fang::typetag; -use fang::Error; +use fang::FangError; use fang::Queueable; use std::thread; use std::time::Duration; @@ -27,9 +27,7 @@ impl MyTask { #[typetag::serde] impl Runnable for MyTask { - fn run(&self, queue: &dyn Queueable) -> Result<(), Error> { - thread::sleep(Duration::from_secs(3)); - + fn run(&self, queue: &dyn Queueable) -> Result<(), FangError> { let new_task = MyTask::new(self.number + 1); log::info!( @@ -40,6 +38,8 @@ impl Runnable for MyTask { queue.insert_task(&new_task).unwrap(); + thread::sleep(Duration::from_secs(2)); + Ok(()) } @@ -68,7 +68,7 @@ impl MyFailingTask { #[typetag::serde] impl Runnable for MyFailingTask { - fn run(&self, queue: &dyn Queueable) -> Result<(), Error> { + fn run(&self, queue: &dyn Queueable) -> Result<(), FangError> { let new_task = MyFailingTask::new(self.number + 1); queue.insert_task(&new_task).unwrap();