mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
update minijinja version
This commit is contained in:
@ -7,12 +7,12 @@ edition = "2021"
|
||||
actix-web.workspace = true
|
||||
|
||||
anyhow = "1"
|
||||
apalis = { version = "0.3", features = ["redis"] }
|
||||
chrono = { version = "0.4.20", default-features = false, features = ["clock", "serde"] }
|
||||
apalis = { version = "0.4", features = ["redis"] }
|
||||
chrono.workspace = true
|
||||
dotenv = "0.15"
|
||||
env_logger.workspace = true
|
||||
log.workspace = true
|
||||
rand.workspace = true
|
||||
serde.workspace = true
|
||||
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
|
||||
tokio-util = "0.7.4"
|
||||
tokio-util.workspace = true
|
||||
|
@ -29,13 +29,13 @@ impl Job for Email {
|
||||
const NAME: &'static str = "send_email";
|
||||
}
|
||||
|
||||
async fn process_email_job(job: Email, _ctx: JobContext) -> Result<JobResult, JobError> {
|
||||
async fn process_email_job(job: Email, _ctx: JobContext) -> Result<(), JobError> {
|
||||
log::info!("sending email to {}", &job.to);
|
||||
|
||||
// simulate time taken to send email
|
||||
tokio::time::sleep(rand_delay_with_jitter()).await;
|
||||
|
||||
Ok(JobResult::Success)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn start_processing_email_queue() -> anyhow::Result<RedisStorage<Email>> {
|
||||
@ -45,16 +45,17 @@ pub(crate) async fn start_processing_email_queue() -> anyhow::Result<RedisStorag
|
||||
// create job monitor(s) and attach email job handler
|
||||
let monitor = Monitor::new().register_with_count(2, {
|
||||
let storage = storage.clone();
|
||||
move |_n| WorkerBuilder::new(storage.clone()).build_fn(process_email_job)
|
||||
move |n| {
|
||||
WorkerBuilder::new(format!("job-handler-{n}"))
|
||||
.with_storage(storage.clone())
|
||||
.build_fn(process_email_job)
|
||||
}
|
||||
});
|
||||
|
||||
// spawn job monitor into background
|
||||
// the monitor manages itself otherwise so we don't need to return a join handle
|
||||
#[allow(clippy::let_underscore_future)]
|
||||
let _ = tokio::spawn(
|
||||
// run_without_signals: don't listen for ctrl-c because Actix Web does
|
||||
monitor.run_without_signals(),
|
||||
);
|
||||
let _ = tokio::spawn(monitor.run());
|
||||
|
||||
Ok(storage)
|
||||
}
|
||||
|
Reference in New Issue
Block a user