Crate apalis_redis

Source
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
ConnectionManager
A ConnectionManager is a proxy that wraps a multiplexed connection and automatically reconnects to the server when necessary.
RedisContext
The context for a redis storage job
RedisError
Represents a redis error.
RedisQueueInfo
Represents redis key names for various components of the RedisStorage.
RedisStorage
Represents a Storage that uses Redis for storage.

Enums§

RedisPollError
Errors that can occur while polling a Redis backend.

Functions§

connect
Shorthand to create a client and connect