Expand description
apalis storage using Redis as a backend
use apalis::prelude::*;
use apalis_redis::{RedisStorage, Config};
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
struct Email {
to: String,
}
async fn send_email(job: Email) -> Result<(), Error> {
Ok(())
}
#[tokio::main]
async fn main() {
let redis_url = std::env::var("REDIS_URL").expect("Missing env variable REDIS_URL");
let conn = apalis_redis::connect(redis_url).await.expect("Could not connect");
let storage = RedisStorage::new(conn);
let worker = WorkerBuilder::new("tasty-pear")
.backend(storage.clone())
.build_fn(send_email);
worker.run().await;
}
Structs§
- Config
- Config for a RedisStorage
- Connection
Manager - A
ConnectionManager
is a proxy that wraps a multiplexed connection and automatically reconnects to the server when necessary. - Redis
Context - The context for a redis storage job
- Redis
Error - Represents a redis error.
- Redis
Queue Info - Represents redis key names for various components of the RedisStorage.
- Redis
Storage - Represents a Storage that uses Redis for storage.
Enums§
- Redis
Poll Error - Errors that can occur while polling a Redis backend.
Functions§
- connect
- Shorthand to create a client and connect