queuekit library

A persistent task queue for Dart and Flutter. Runs events in order, retries failures, keeps dependent events in order and restores the queue across app restarts.

Classes

Event<T extends Object?>
A unit of work that a Queue runs.
EventSerializer<T extends Event<Object?>>
Converts the events of one type, T, to and from JSON for a HydratedQueue.
ExponentialBackoffRetryConfig
Retries after delay × multiplier ^ retryCount: with a multiplier of 2, delay × 2, then delay × 4, and so on.
FailDecision
Fails an event permanently.
FakeQueueClock
A controllable QueueClock for tests.
HydratedQueue
A Queue that saves itself whenever it changes and restores itself with hydrate.
InMemoryQueueStore
An in-memory QueueStore whose apply batches are atomic.
JsonSerializer<T>
A pair of functions that convert a T to and from JSON.
LinearRetryConfig
Retries after delay × retryCount: delay, then twice delay, and so on.
PauseDecision
Pauses the queue and keeps the failed event at the front of the current queue.
Queue
Runs events one at a time, in the order they were added, while startListenable is started.
QueueChange
A single per-record mutation applied to a QueueStore as part of an atomic change set.
QueueClock
Supplies the current time and schedules timers for a Queue.
QueueRecord
The persisted representation of a single Event in a QueueStore.
QueueRecordInsert
Inserts record into a QueueStore.
QueueRecordRemove
Removes the record with id from a QueueStore.
QueueRecordUpdate
Updates an existing record (keyed by QueueRecord.id) in a QueueStore.
QueueStartListenable
Starts and pauses a queue.
QueueStore
Per-event storage for a HydratedQueue.
RetryAtDecision
Schedules a failed event to run again at nextAttemptAt.
RetryConfig
Decides when a failed event is retried.
RetryDecision
The action a Queue takes after an Event.run attempt throws.

Enums

QueueRecordState
The persisted lifecycle state of a QueueRecord in a QueueStore.

Properties

exponentialBackoffRetryConfigSerializer → JsonSerializer<ExponentialBackoffRetryConfig>
The JsonSerializer of ExponentialBackoffRetryConfig. Persists maxRetries, delay in milliseconds, multiplier and retryCount.
final
linearRetryConfigSerializer → JsonSerializer<LinearRetryConfig>
The JsonSerializer of LinearRetryConfig. Persists maxRetries, delay in milliseconds and retryCount.
final

Typedefs

FromJson<T> = T Function(Map<String, dynamic> json)
Rebuilds a T from the map produced by the matching ToJson.
OnError<T extends Event<U>, U extends Object?> = FutureOr<void> Function(T event, EventFailedException error, StackTrace stackTrace)
The error callback of Queue.listenAll and Queue.listenWhere.
QueueListenerResult<T extends Event<U>, U extends Object?> = ({T event, U result})
The record emitted on Queue.results for every event that ran successfully.
QueueRecordFilter = bool Function(QueueRecord record)
A predicate that selects which persisted QueueRecords to restore during HydratedQueue.hydrate.
RetryPolicy = RetryDecision? Function(Event<Object?> event, Object error, int attemptCount)
Decides what a Queue should do when event fails with error on attempt attemptCount.
ToJson<T> = Map<String, dynamic> Function(T data)
Converts a T to a JSON-encodable map.

Exceptions / Errors

DependencyFailedException
The error of an EventFailedException emitted for an event that could not run because an event it depends on failed permanently.
EventFailedException<T>
Emitted on Queue.results when an event fails.
RetryExceededException
Thrown by RetryConfig.retry when it is called with no retries left.