|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
In-memory implementation of IOfflineQueue, owned by one executor. More...
#include <offline_queue.hpp>
Public Member Functions | |
| InMemoryOfflineQueue (::morph::exec::IExecutor &owner, std::optional< std::size_t > maxDepth=std::nullopt) | |
Constructs an in-memory queue belonging to owner, optionally bounded. | |
| uint64_t | enqueue (std::string payload) override |
Appends payload and returns a monotonically increasing id. On the owner. | |
| uint64_t | enqueue (std::string payload, std::string idempotencyKey) override |
Appends payload carrying idempotencyKey and returns a monotonically increasing id. On the owner. | |
| std::vector< QueueItem > | drain () const override |
| Returns a snapshot of all pending items. On the owner. | |
| std::size_t | size () const override |
| Returns the number of pending items. On the owner. | |
| std::optional< std::size_t > | maxDepth () const override |
| Returns the configured maximum depth, or std::nullopt if unbounded. Callable anywhere: fixed at construction. | |
| void | markDone (uint64_t itemId) override |
Removes the item with itemId from the queue, on the owner. | |
| void | setAttempts (uint64_t itemId, Attempts attempts) override |
Updates the persisted attempt count on the in-deque item with itemId, on the owner. No-op if itemId is not found. | |
| ::morph::async::Completion< std::vector< QueueItem > > | drain (::morph::exec::IExecutor &replyExec) const |
Snapshots the pending items on the queue's owner; delivered on replyExec. | |
| ::morph::async::Completion< uint64_t > | enqueue (::morph::exec::IExecutor &replyExec, std::string payload, std::string idempotencyKey={}) |
Appends payload carrying idempotencyKey on the queue's owner; the new item's id is delivered on replyExec. | |
| ::morph::async::Completion< std::size_t > | size (::morph::exec::IExecutor &replyExec) const |
Counts the pending items on the queue's owner; delivered on replyExec. | |
| Public Member Functions inherited from morph::offline::IOfflineQueue | |
| ::morph::async::Completion< uint64_t > | enqueue (::morph::exec::IExecutor &replyExec, std::string payload, std::string idempotencyKey={}) |
Appends payload carrying idempotencyKey on the queue's owner; the new item's id is delivered on replyExec. | |
| ::morph::async::Completion< std::vector< QueueItem > > | drain (::morph::exec::IExecutor &replyExec) const |
Snapshots the pending items on the queue's owner; delivered on replyExec. | |
| ::morph::async::Completion< std::size_t > | size (::morph::exec::IExecutor &replyExec) const |
Counts the pending items on the queue's owner; delivered on replyExec. | |
Protected Member Functions | |
| ::morph::async::Completion< uint64_t > | askEnqueue (::morph::exec::IExecutor &replyExec, std::string payload, std::string idempotencyKey) override |
Enqueues on the owner, answered on replyExec. | |
| ::morph::async::Completion< std::vector< QueueItem > > | askDrain (::morph::exec::IExecutor &replyExec) const override |
Snapshots on the owner, answered on replyExec. | |
| ::morph::async::Completion< std::size_t > | askSize (::morph::exec::IExecutor &replyExec) const override |
Counts on the owner, answered on replyExec. | |
| Protected Member Functions inherited from morph::offline::IOfflineQueue | |
| virtual void | setIdempotencyKey (uint64_t itemId, std::string idempotencyKey) |
| Stamps an idempotency key onto an already-enqueued item. | |
In-memory implementation of IOfflineQueue, owned by one executor.
Suitable for testing and for applications that do not require persistence across process restarts. Items are stored in a std::deque that belongs to the executor given at construction (see IOfflineQueue, "One owner").
Definition at line 425 of file offline_queue.hpp.
|
inlineexplicit |
Constructs an in-memory queue belonging to owner, optionally bounded.
| owner | The executor every access runs on; must run one task at a time. Borrowed: it must outlive this queue and run what it posts. |
| maxDepth | Maximum number of pending items enqueue() will admit before throwing OfflineQueueFullError; std::nullopt (the default) means unbounded. |
Definition at line 437 of file offline_queue.hpp.
|
inlinenodiscardoverridevirtual |
Appends payload and returns a monotonically increasing id. On the owner.
| payload | Serialised action to store. |
Implements morph::offline::IOfflineQueue.
Definition at line 444 of file offline_queue.hpp.
|
inlinenodiscardoverridevirtual |
Appends payload carrying idempotencyKey and returns a monotonically increasing id. On the owner.
| payload | Serialised action to store. |
| idempotencyKey | Stable dedup token; stored verbatim on the item. |
| OfflineQueueFullError | if the queue is already at maxDepth(). |
Reimplemented from morph::offline::IOfflineQueue.
Definition at line 452 of file offline_queue.hpp.
|
inlinenodiscardoverridevirtual |
Returns a snapshot of all pending items. On the owner.
Implements morph::offline::IOfflineQueue.
Definition at line 459 of file offline_queue.hpp.
|
inlinenodiscardoverridevirtual |
Returns the number of pending items. On the owner.
Reimplemented from morph::offline::IOfflineQueue.
Definition at line 466 of file offline_queue.hpp.
|
inlinenodiscardoverridevirtual |
Returns the configured maximum depth, or std::nullopt if unbounded. Callable anywhere: fixed at construction.
Reimplemented from morph::offline::IOfflineQueue.
Definition at line 471 of file offline_queue.hpp.
|
inlineoverridevirtual |
Removes the item with itemId from the queue, on the owner.
No-op if itemId is not found.
| itemId | Id of the item to remove. |
Implements morph::offline::IOfflineQueue.
Definition at line 477 of file offline_queue.hpp.
|
inlineoverridevirtual |
Updates the persisted attempt count on the in-deque item with itemId, on the owner. No-op if itemId is not found.
InMemoryOfflineQueue does not itself survive a process restart, but overriding this hook lets a fresh SyncWorker constructed over the same instance observe a durable-style cumulative attempt count — used to simulate cross-restart dead-lettering in tests.
| itemId | Id of the item to update. |
| attempts | New attempt count to store. |
Reimplemented from morph::offline::IOfflineQueue.
Definition at line 496 of file offline_queue.hpp.
|
inlinenodiscardoverrideprotectedvirtual |
Enqueues on the owner, answered on replyExec.
| replyExec | Where the answer is delivered. |
| payload | Serialised action to store. |
| idempotencyKey | Stable dedup token; may be empty. |
Reimplemented from morph::offline::IOfflineQueue.
Definition at line 512 of file offline_queue.hpp.
|
inlinenodiscardoverrideprotectedvirtual |
Snapshots on the owner, answered on replyExec.
| replyExec | Where the answer is delivered. |
Reimplemented from morph::offline::IOfflineQueue.
Definition at line 525 of file offline_queue.hpp.
|
inlinenodiscardoverrideprotectedvirtual |
Counts on the owner, answered on replyExec.
| replyExec | Where the answer is delivered. |
Reimplemented from morph::offline::IOfflineQueue.
Definition at line 535 of file offline_queue.hpp.
|
inlinenodiscard |
Snapshots the pending items on the queue's owner; delivered on replyExec.
| replyExec | Where the answer is delivered. Borrowed: it must outlive the completion. |
Definition at line 335 of file offline_queue.hpp.
|
inlinenodiscard |
Appends payload carrying idempotencyKey on the queue's owner; the new item's id is delivered on replyExec.
The form of enqueue() for a caller that is not on the queue's owner. A full queue rejects the completion with OfflineQueueFullError.
| replyExec | Where the answer is delivered, and where the caller attaches to it. Borrowed: it must outlive the completion. |
| payload | Serialised action to persist. |
| idempotencyKey | Stable dedup token for the logical op; may be empty. |
Definition at line 325 of file offline_queue.hpp.
|
inlinenodiscard |
Counts the pending items on the queue's owner; delivered on replyExec.
| replyExec | Where the answer is delivered. Borrowed: it must outlive the completion. |
Definition at line 345 of file offline_queue.hpp.