1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

chore: update deps

This commit is contained in:
Rob Ede
2024-07-07 02:51:12 +01:00
parent dca1d50430
commit 697d2ec49d
12 changed files with 577 additions and 646 deletions

View File

@ -6,11 +6,12 @@ edition = "2021"
[dependencies]
actix-web.workspace = true
anyhow = "1"
apalis = { version = "0.4", features = ["redis"] }
chrono.workspace = true
color-eyre.workspace = true
dotenvy.workspace = true
env_logger.workspace = true
eyre.workspace = true
log.workspace = true
rand.workspace = true
serde.workspace = true

View File

@ -14,7 +14,8 @@ mod routes;
pub(crate) type ItemCache = Mutex<HashMap<String, DateTime<Utc>>>;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
async fn main() -> eyre::Result<()> {
color_eyre::install()?;
dotenvy::dotenv().ok();
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));

View File

@ -3,7 +3,7 @@
use std::time::Duration;
use apalis::{prelude::*, redis::RedisStorage};
use rand::Rng as _;
use rand::distributions::{Alphanumeric, DistString as _};
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
@ -13,14 +13,8 @@ pub(crate) struct Email {
impl Email {
pub(crate) fn random() -> Self {
let user = (&mut rand::thread_rng())
.sample_iter(rand::distributions::Alphanumeric)
.take(10)
.map(char::from)
.collect::<String>();
let user = Alphanumeric.sample_string(&mut rand::thread_rng(), 10);
let to = format!("{user}@fake-mail.com");
Self { to }
}
}
@ -38,7 +32,7 @@ async fn process_email_job(job: Email, _ctx: JobContext) -> Result<(), JobError>
Ok(())
}
pub(crate) async fn start_processing_email_queue() -> anyhow::Result<RedisStorage<Email>> {
pub(crate) async fn start_processing_email_queue() -> eyre::Result<RedisStorage<Email>> {
let redis_url = std::env::var("REDIS_URL").expect("Missing env variable REDIS_URL");
let storage = RedisStorage::connect(redis_url).await?;