morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::offline::QueueItem Struct Reference

An item stored in the offline queue. More...

#include <offline_queue.hpp>

Public Attributes

uint64_t id {}
 Stable identifier assigned at enqueue time.
std::string payload
 Opaque serialised representation of the queued action.
std::string idempotencyKey
 Optional caller-supplied idempotency key that is stable across subsystems and process restarts for one logical operation.
uint32_t attempts {0}
 Durable retry count for this item, authoritative when the queue persists it.

Detailed Description

An item stored in the offline queue.

The payload is an opaque string — the caller controls the serialisation format (JSON, binary-hex, plain text, etc.).

Definition at line 85 of file offline_queue.hpp.

Member Data Documentation

◆ id

uint64_t morph::offline::QueueItem::id {}

Stable identifier assigned at enqueue time.

Local to this queue instance; it is not a cross-subsystem idempotency key (it is queue-local and the journal never sees it; both shipped durable queues re-present the stored id after a restart). Use idempotencyKey to dedup a replay against already-applied ops.

Definition at line 92 of file offline_queue.hpp.

◆ payload

std::string morph::offline::QueueItem::payload

Opaque serialised representation of the queued action.

Definition at line 95 of file offline_queue.hpp.

◆ idempotencyKey

std::string morph::offline::QueueItem::idempotencyKey

Optional caller-supplied idempotency key that is stable across subsystems and process restarts for one logical operation.

Empty by default. When set, it is the shared dedup token that lets a replay consumer recognise an op the journal (or a previous replay) has already applied and skip it, instead of double-applying. The offline queue and the journal replay have no shared identity otherwise — the queue's id is queue-local and the journal's seq is journal-local — so a host that replays through both paths must wire this key (see docs/spec/offline/offline.md, "`idempotencyKey`: deduping against the journal"). The value is opaque to the queue; a good choice is a stable content hash or a client-minted operation id (e.g. a UUID) reused if the same op is re-enqueued.

The queue never interprets the key, and the interface does not require an implementation to enforce uniqueness on it — a replay consumer must therefore always dedup on the key itself, because a conforming queue may hand it the same key twice. An implementation is nonetheless permitted to dedup a non-empty key at enqueue time as a strengthening of that floor; see IOfflineQueue::enqueue(std::string, std::string) for exactly what a dedup hit does.

Definition at line 118 of file offline_queue.hpp.

◆ attempts

uint32_t morph::offline::QueueItem::attempts {0}

Durable retry count for this item, authoritative when the queue persists it.

Defaults to 0. A queue that overrides IOfflineQueue::setAttempts() to store this value makes the retry budget survive a process restart: SyncWorker seeds its own attempt counter from the larger of this field and its in-memory count, and writes the updated count back via setAttempts() after every failed replay. A queue that leaves setAttempts() as the default no-op never advances this field, so SyncWorker's in-memory counter stays authoritative — today's process-local retry behavior, unchanged.

Definition at line 131 of file offline_queue.hpp.


The documentation for this struct was generated from the following file: