durable_queue library

Persistent, retryable task execution for Dart and Flutter.

Tasks run at least once. Persisting a task does not make a terminated process wake up; call DurableQueue.start again on the next launch.

Classes

DurableQueue
Durable task queue.
DurableTask
A serializable unit of work.
ExponentialRetryPolicy
A policy that doubles the delay after each failed attempt.
FakeQueueClock
Manually advanced clock for deterministic tests.
FixedRetryPolicy
A policy that waits a constant duration between attempts.
MemoryQueueStorage
Indexed in-memory QueueStorage.
NoRetryPolicy
A policy that allows a single attempt.
QueueClock
Time source used for timestamps and retry delays.
QueueDelay
A cancellable wait returned by QueueClock.delayUntil.
QueueEvent
A lifecycle notification.
QueueStorage
Persistence boundary for the queue.
QueueStorageFailure
A worker storage operation failed and will be retried.
RetryPolicy
How many times a task may run, and how long to wait between failures.
StoredTask
Persisted record for one task.
SystemQueueClock
Clock backed by DateTime.now and Timer.
TaskCancelled
A task was cancelled.
TaskCompleted
A handler invocation finished successfully.
TaskContext
Information about the attempt currently executing.
TaskEnqueued
A new task was stored.
TaskFailed
A task will not be attempted again.
TaskFailure
Diagnostic record for the latest failed attempt.
TaskRetryScheduled
A failed attempt was scheduled to run again.
TaskStarted
A handler invocation has started.

Enums

DependencyFailurePolicy
What happens to a waiting task when one of its dependencies does not complete.
QueueRunState
Lifecycle of a DurableQueue instance.
TaskStatus
Explicit lifecycle of a persisted task.

Typedefs

RandomFraction = double Function()
Supplies the [0, 1) fraction used by jitter.
RetryPredicate = bool Function(Object error, StackTrace stackTrace)
Decides whether error should be retried.
TaskDecoder<T extends DurableTask> = T Function(Map<String, dynamic> json)
Rebuilds a task from the JSON stored by DurableTask.toJson.
TaskHandler<T extends DurableTask> = Future<void> Function(T task, TaskContext context)
Executes one attempt.
TaskIdGenerator = String Function()
Supplies a new task id.

Exceptions / Errors

DependencyFailedException
Recorded when a waiting task cannot run because a dependency did not complete.
TaskCancelledException
Thrown by a handler to cooperatively acknowledge cancellation.
TaskDecodeException
Thrown when a persisted payload cannot be turned back into a task.
TaskInterruptedException
Recorded when a task is still running after the process restarts.
TaskNotFoundException
Thrown when an operation targets a task id that is not in storage.
UnknownTaskTypeException
Thrown when a task type has no registered handler.