JsonFileOutboxStore class

An OutboxStore that keeps the whole queue in one JSON file.

Every commit rewrites the file atomically: the new content is written to <path>.tmp, flushed to disk, and then renamed over <path>. A crash at any point leaves either the old or the new file, never a torn one. A leftover <path>.tmp from an interrupted write is ignored.

Rewriting the whole file suits queues of up to a few thousand entries. For larger queues implement OutboxStore on a database.

Implemented types

Constructors

JsonFileOutboxStore(String path)
Creates a store backed by the file at path. Parent directories are created on the first write.

Properties

hashCode → int
The hash code for this object.
no setterinherited
path → String
Location of the JSON file.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

commit({Iterable<OutboxEntry> upserts = const [], Iterable<String> removals = const []}) → Future<void>
Atomically inserts or replaces upserts (matched by id) and deletes the entries whose ids are in removals. Unknown ids in removals are ignored.
override
loadAll() → Future<List<OutboxEntry>>
Every stored entry, ordered by OutboxEntry.sequence.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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