Expand description
printobserver-store-api.
Owns: the port durable state speaks through: the trait for recording and replaying observations, decisions and job history, the shapes its methods carry, the two constants and the one resolution the history read is specified by, plus that port’s own error type.
May depend on: printobserver-types only. A port that named an
implementation would stop being a port.
§The history read has four behavioural facts, and they are settled here
A signature carries none of them, and a trait that is structurally exact with all four unstated is an incomplete port, so this crate leaves an implementation exactly one answer to take for each rather than leaving them to whoever implements the trait:
- The default history window is
DEFAULT_HISTORY_WINDOW. - The maximum history limit is
MAX_HISTORY_LIMIT, and it is above the default. StorePort::historyanswers newest first.- An empty
kindsin aHistoryQuerymeans every kind, not no kinds.
The limit rule has one implementation here too — resolve_history_limit —
so that refusing rather than clamping is a property of this contract and not
of whoever implemented the trait. There is exactly one exported constant of
each kind and exactly one exported resolution, so a consumer has one thing
to import and no choice to make.
Whether an implementation obeys the four is proven where the implementations are, by one conformance suite driving both of them.
§Minting an identifier
StorePort::record_action is the only method that takes an
ActionRequest or a PolicyDecision at all, and it takes them only
together, so this surface offers no way to ask for a fresh ActionId
for a request whose decision was not recorded beside it. Other methods
answer records that may carry an identifier an earlier record_action
minted — StorePort::append_event answers an
EventRecord whose action-event
payloads carry one — and that is stated rather than forbidden. That no
method but record_action mints one is a property of an implementation’s
bodies rather than of a signature, and is established by the store
implementation’s own conformance suite.
§Why the methods answer a boxed future
Every method is asynchronous, and the trait is dyn-compatible and shareable
across threads, because the supervision core holds all four ports behind
Arc<dyn Port>. An async fn in a trait is not dyn-compatible, so each
method answers a BoxFuture instead.
Structs§
- Audit
Page - One page of a print’s whole history, and the cursor that follows it.
- Event
Draft - One event on its way into the store, before the store mints its identifier.
- History
Query - Which of a print’s events to read.
Enums§
- Image
Lookup - What the store found when asked for an image.
- Settle
Outcome - What settling an intervention did.
- Store
Error - Why the store did not do what it was asked.
Constants§
- DEFAULT_
HISTORY_ WINDOW - How many events a history read answers when the caller asks for no limit.
- MAX_
HISTORY_ LIMIT - The most events a history read will answer, however many are asked for.
Traits§
- Store
Port - The port durable state speaks through.
Functions§
- resolve_
history_ limit - Resolve the limit a history read asks for, refusing one above the maximum.
Type Aliases§
- BoxFuture
- A future this port’s methods answer with, in the one shape a trait object can carry.