start_worker

Function start_worker 

Source
pub async fn start_worker(
    broker_url: &str,
    queue: &str,
    mode: &str,
    concurrency: usize,
    max_retries: u32,
    timeout: u64,
) -> Result<()>
Expand description

Start a worker with the given configuration.

Creates and runs a worker that processes tasks from the specified queue. The worker will run until it receives a shutdown signal (Ctrl+C).

§Arguments

  • broker_url - Redis connection URL (e.g., redis://localhost:6379)
  • queue - Queue name to process tasks from
  • mode - Queue mode: “fifo” for FIFO, “priority” for priority-based
  • concurrency - Maximum number of concurrent tasks to process
  • max_retries - Maximum retry attempts for failed tasks
  • timeout - Task execution timeout in seconds

§Returns

Returns Ok(()) on successful shutdown, or an error if worker fails to start.

§Examples

// Start a FIFO worker with 4 concurrent tasks
start_worker(
    "redis://localhost:6379",
    "my_queue",
    "fifo",
    4,
    3,
    300
).await?;