redis_task_queue library
A small Redis-backed task queue for server-side Dart.
Enqueue work from your request path with QueueClient, immediately or scheduled for a future time, and process it in a separate Worker with retries, a dead-letter list, and weighted queues.
Classes
- DeadLetter
- A task that exhausted its retries and is parked on the dead-letter list, together with why it failed.
- QueueClient
- Enqueues tasks onto Redis. Safe to keep one client for the lifetime of your app and reuse it: enqueuing is a single LPUSH (a single ZADD for a scheduled task). A dropped connection doesn't end that lifetime either: the next call reconnects and retries once before giving up, so a Redis restart or failover doesn't permanently break a client that survives it.
- QueueStats
- A snapshot of how much work is sitting in the queue right now.
- Task
- A unit of work to run outside the request path.
- TaskContext
- What the worker knows about the run in progress, handed to a handler alongside the task.
- Worker
- Consumes tasks from Redis and runs their handlers.
Typedefs
- TaskDeadLetterCallback = void Function(Task task, TaskContext context, Object error, StackTrace stackTrace)
- Called when a task has exhausted its retries and been moved to the dead-letter list.
- TaskErrorCallback = void Function(Task task, TaskContext context, Object error, StackTrace stackTrace)
- Called each time a task handler throws, before the worker decides what to do next.
-
TaskHandler
= FutureOr<
void> Function(Task task, TaskContext context) - A handler processes one task type. Throwing signals failure, which triggers a retry (up to the envelope's maxRetries); returning normally marks it done.
Exceptions / Errors
- TaskQueueConnectionException
- Redis could not be reached, or the connection died mid-command.
- TaskQueueException
- The base type for every failure this package reports.
- TaskQueueServerException
- Redis received the command and answered with an error.