ZenithOutboxEngine class

An offline mutation queue that ensures a signed-out tenant's queued writes cannot be dispatched under another user's session, with error resilience, capped exponential backoff windows, clock-drift guards, and dead-letter queue isolation.

Usage:

outbox.enqueue(tenantId: 'user_a', action: 'UpdateBio', payload: {});
outbox.setActiveTenant('user_b');
await outbox.flush(dispatch); // user_a's mutation is NOT flushed

Constructors

ZenithOutboxEngine()

Properties

deadLetterQueue → List<OutboxMutation>
Unmodifiable view of dead-lettered mutations.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

deadLetterCount(String tenantId) → int
Returns the number of dead-letter mutations for tenantId.
enqueue({required String tenantId, required String action, required Map<String, dynamic> payload, int maxRetries = 3}) → void
Enqueues a mutation for tenantId.
flush(Future<void> dispatcher(OutboxMutation mutation), {void onMutationError(OutboxMutation mutation, Object error)?, bool ignoreBackoff = false, Duration baseBackoff = const Duration(milliseconds: 100), Duration maxBackoff = const Duration(seconds: 60)}) → Future<void>
Dispatches all pending mutations for the active tenant via dispatcher.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pendingCount(String tenantId) → int
Returns the number of pending (unflushed) mutations for tenantId.
setActiveTenant(String? tenantId) → void
Sets the active tenant, or null on sign-out. Invalidates any pending pass.
toString() → String
A string representation of this object.
inherited

Operators

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