|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Interface for durable storage of executed-action entries. More...
#include <action_log.hpp>
Public Member Functions | |
| virtual void | append (LogEntry entry)=0 |
Appends entry. Implementations assign entry.seq. | |
| virtual void | flush ()=0 |
| Pushes any buffered entries to the durable backend. No-op for sinks with nothing to buffer (e.g. InMemoryActionLog). | |
| virtual std::vector< LogEntry > | entries (std::string_view entityKey={}) const =0 |
| Returns recorded entries in append order. | |
| virtual ::morph::exec::IExecutor * | owner () const noexcept |
| The executor this log's state belongs to, or null for an implementation that has none. | |
| ::morph::async::Completion< std::vector< LogEntry > > | entries (::morph::exec::IExecutor &replyExec, std::string entityKey={}) const |
Returns recorded entries in append order, read on the log's owner and delivered on replyExec. | |
| ::morph::async::Completion< bool > | flush (::morph::exec::IExecutor &replyExec) |
Pushes buffered entries to the durable backend on the log's owner; the answer is delivered on replyExec. | |
Protected Member Functions | |
| virtual ::morph::async::Completion< std::vector< LogEntry > > | askEntries (::morph::exec::IExecutor &replyExec, std::string entityKey) const |
| What entries(replyExec, entityKey) asks. The default reads entries(entityKey) where it is called, for an implementation with no owner; one with an owner reads there. | |
| virtual ::morph::async::Completion< bool > | askFlush (::morph::exec::IExecutor &replyExec) |
| What flush(replyExec) asks. The default flushes where it is called, for an implementation with no owner; one with an owner flushes there. | |
Interface for durable storage of executed-action entries.
Entries are never removed by the framework — this is a permanent, append-only record, unlike morph::offline::IOfflineQueue (whose markDone() deletes items once retried successfully). Implementations range from in-memory (InMemoryActionLog) to file, SQL, or network-backed stores supplied by the host application.
Definition at line 174 of file action_log.hpp.
|
pure virtual |
Appends entry. Implementations assign entry.seq.
An implementation that can fail to record the entry must throw. Returning normally is the sink's promise that the entry is recorded (or, for a buffering sink, that it will be by the next successful flush()); see flush() for why silence is not an option here.
| entry | Entry to append. |
| std::exception | (implementation-defined) if the entry could not be recorded. |
Implemented in morph::journal::FileActionLog, morph::journal::InMemoryActionLog, and morph::journal::SessionLog.
|
pure virtual |
Pushes any buffered entries to the durable backend. No-op for sinks with nothing to buffer (e.g. InMemoryActionLog).
Must throw if the data did not reach the backend. The return type is void, so throwing is the only channel an implementation has, and callers rely on it: OutboxRelay::relay() calls markRelayed() directly after this, and a silently-failed flush would mark rows relayed in the model's own store while nothing was durably written — dropping them from the outbox and from the log, with no error anywhere. An implementation that cannot fail (nothing to buffer) simply never throws.
| std::exception | (implementation-defined) if buffered entries could not be made durable. |
Implemented in morph::journal::FileActionLog, morph::journal::InMemoryActionLog, and morph::journal::SessionLog.
|
nodiscardpure virtual |
Returns recorded entries in append order.
An implementation with an owner answers only there (see owner()); a caller elsewhere asks through entries(replyExec, entityKey).
| entityKey | If non-empty, restricts the result to that entity's entries. |
Implemented in morph::journal::FileActionLog, morph::journal::InMemoryActionLog, and morph::journal::SessionLog.
|
inlinenodiscardvirtualnoexcept |
The executor this log's state belongs to, or null for an implementation that has none.
Every log morph ships has one: its append() runs there (posted from anywhere else), and its entries()/flush() answer only there. What a caller on a model's strand names as the reply executor of entries(replyExec, …) or flush(replyExec).
Reimplemented in morph::journal::FileActionLog, morph::journal::InMemoryActionLog, and morph::journal::SessionLog.
Definition at line 219 of file action_log.hpp.
|
inlinenodiscard |
Returns recorded entries in append order, read on the log's owner and delivered on replyExec.
The form for a caller that is not on the owner: a model's strand, an application thread the log does not belong to. The read is ordered after every append() posted to the owner before it.
| replyExec | Where the answer is delivered, and where the caller attaches to it. Borrowed: it must outlive the completion. |
| entityKey | If non-empty, restricts the result to that entity's entries. |
Definition at line 231 of file action_log.hpp.
|
inlinenodiscard |
Pushes buffered entries to the durable backend on the log's owner; the answer is delivered on replyExec.
The form of flush() for a caller that is not on the owner. It is ordered after every append() posted to the owner before it.
| replyExec | Where the answer is delivered. Borrowed: it must outlive the completion. |
Definition at line 245 of file action_log.hpp.
|
inlinenodiscardprotectedvirtual |
What entries(replyExec, entityKey) asks. The default reads entries(entityKey) where it is called, for an implementation with no owner; one with an owner reads there.
| replyExec | Where the answer is delivered. |
| entityKey | If non-empty, restricts the result to that entity's entries. |
Reimplemented in morph::journal::FileActionLog, morph::journal::InMemoryActionLog, and morph::journal::SessionLog.
Definition at line 256 of file action_log.hpp.
|
inlinenodiscardprotectedvirtual |
What flush(replyExec) asks. The default flushes where it is called, for an implementation with no owner; one with an owner flushes there.
| replyExec | Where the answer is delivered. |
Reimplemented in morph::journal::FileActionLog.
Definition at line 274 of file action_log.hpp.