Skip to main content

Module queue

Module queue 

Source
Expand description

In-memory background job queue with retry, delayed jobs, and dead letter support. In-memory background job queue with named queues, retry policies, and dead letter support.

Provides a lightweight task queue for deferring work to background workers — useful for sending emails, webhooks, async processing, etc.

§Features

  • Named queues — separate logical channels (e.g. "email", "webhook")
  • Configurable workers — per-queue concurrency limit
  • Retry policy — fixed or exponential backoff with max attempts
  • Delayed jobs — schedule execution after a duration
  • Dead letter queue — failed jobs stored for inspection
  • Graceful shutdown — drain in-flight jobs before exit

§Examples

use tako::queue::{Queue, RetryPolicy, Job};
use std::time::Duration;

let queue = Queue::builder()
    .workers(4)
    .retry(RetryPolicy::exponential(3, Duration::from_secs(1)))
    .build();

queue.register("send_email", |job: Job| async move {
    let to: String = job.deserialize()?;
    println!("Sending email to {to}");
    Ok(())
});

queue.push("send_email", &"user@example.com").await.unwrap();

Structs§

DeadJob
A failed job stored in the dead letter queue.
Job
A job passed to a handler function.
Queue
An in-memory background job queue.
QueueBuilder
Builder for configuring a Queue.

Enums§

QueueError
Error type for queue operations.
RetryPolicy
Retry policy for failed jobs.