InMemoryResultBackend class

Simple in-memory result backend used for tests and local development.

Implemented types

Constructors

InMemoryResultBackend({Duration defaultTtl = const Duration(days: 1), Duration groupDefaultTtl = const Duration(days: 1), Duration heartbeatTtl = const Duration(seconds: 60)})
Creates an in-memory backend with configurable TTLs.

Properties

defaultTtl Duration
Default expiration applied to task statuses.
final
groupDefaultTtl Duration
Default expiration applied to group/chord metadata.
final
hashCode int
The hash code for this object.
no setterinherited
heartbeatTtl Duration
Time-to-live applied to worker heartbeat entries.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportsAtomicTerminalWrites bool
Whether this backend provides a cross-process atomic terminal write.
no setteroverride

Methods

addGroupResult(String groupId, TaskStatus status) Future<GroupStatus?>
Adds a result to a group, returning the updated aggregate.
override
claimChord(String groupId, {String? callbackTaskId, DateTime? dispatchedAt}) Future<bool>
Attempts to claim responsibility for dispatching the chord callback for groupId. Returns true only for the first caller; subsequent callers receive false once the chord has been claimed. When callbackTaskId or dispatchedAt are provided, implementations SHOULD persist them with the group metadata so other components can observe dispatch progress.
override
close() Future<void>
Releases any resources held by the backend.
override
dispose() Future<void>
Cancels timers and closes any active watchers.
expire(String taskId, Duration ttl) Future<void>
Extends the TTL for a task status entry.
override
get(String taskId) Future<TaskStatus?>
Returns the latest task status if still within its TTL.
override
getGroup(String groupId) Future<GroupStatus?>
Returns the group status if it has not expired.
override
getWorkerHeartbeat(String workerId) Future<WorkerHeartbeat?>
Retrieves a worker heartbeat if still within its TTL.
override
initGroup(GroupDescriptor descriptor) Future<void>
Initializes a group/chord tracking entry.
override
listTaskStatuses(TaskStatusListRequest request) Future<TaskStatusPage>
Lists task status records using the provided request filters.
override
listWorkerHeartbeats() Future<List<WorkerHeartbeat>>
Lists all non-expired worker heartbeats.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(String taskId, TaskState state, {Object? payload, TaskError? error, int attempt = 0, Map<String, Object?> meta = const {}, Duration? ttl}) Future<void>
Sets the status for the task with the given taskId.
override
setTerminalIfAbsent(TaskStatus status, {Duration? ttl}) Future<bool>
Attempts to persist status as the task's terminal state.
override
setWorkerHeartbeat(WorkerHeartbeat heartbeat) Future<void>
Stores or refreshes a worker heartbeat entry.
override
toString() String
A string representation of this object.
inherited
watch(String taskId) Stream<TaskStatus>
Watches updates for a task ID, emitting new statuses.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited