Module object
Expand description
Keyed objects: handlers per key with key/value state, built from Fusee’s records.
An object type is a set of handlers; each key of the type is one object
with its own key/value state (JSON values under string keys). A key is a
long-lived run with workflow ID <type>/<key>, marked
policy::OBJECT in its Start record, and each call is an update of
that run. So there is no new kind of storage: a key is recovered,
replicated, parked, listed and exported as a run, and every client that
can send an update-with-start can call an object.
What the engine adds (in [crate::runtime]):
- Exclusive calls run one at a time per key, in the order they reach
the key’s shard. A call is accepted (its
Updaterecord appended) when its handler starts; an exclusive call that arrives while another runs waits for the key, in memory, in arrival order. Shared calls are accepted at once. - State lives next to the run. Reads are synchronous host calls and
are not journaled. An exclusive handler’s writes are its own until it
returns; then they are committed with its result, in its
UpdateDonerecord (encode_delta). A failed handler commits nothing. Commits happen when handlers return, at positions the journal fixes, so a replayed handler reads what it read the first time. - Calls from workflow code are
Childoperations flaggedpolicy::OBJECT(encode_call): they go through the durable outbox, the key’sUpdaterecord names the caller, and itsUpdateDonesends the result back as a child result. - Retries with an ID run once: within a run by the update ID, and
across compaction through the calls the snapshot keeps (
Kept). - Compaction: when no handler runs and the key’s run has made
COMPACT_OPSjournal operations, or it is idle and about to be parked, the engine continues the run as new with aSnapshotas the new run’s input. Loading or recovering a key replays at most that much handler code, and an idle key’s journal is one record.
See docs/features.md#objects-keyed-state for the semantics.
Re-exports§
pub use edit::EDIT_HANDLER;
Modules§
- edit
- Edits of a key’s state from outside its handlers.
Structs§
- Call
Options - The options of a call to an object’s handler.
- Kept
- A finished call a key remembers across compaction, so a retry with its ID gets its result instead of running again.
- Object
- A registered object type.
- Object
Call - A key of an object type, called from workflow code (or another
object’s handler):
Ctx::object. - Object
Ctx - What an object’s handler gets: the workflow context of the key’s run, plus its state and key.
- Object
Def - What the runtime knows about an object type: which handlers are shared (every other handler is exclusive).
- Object
Detail - What
inspectadds for an object run. - Object
Handlers - An object type’s handlers, and the workflow code they become: what
ObjectTyperegisters on an engine, and what a simulator or another registry takes (into_code). - Object
Ref - A key of an object type, to call from outside workflow code.
- Object
Type - An object type being defined:
Engine::object, then its handlers, thenregister. - Pending
Call - A call to a key that has not finished: running, or waiting for the key.
- Snapshot
- A key’s state and remembered calls: the input of each of its runs.
- State
- A key’s state, as a handler sees it.
Constants§
- COMPACT_
OPS - Journal operations after which a key’s run is compacted at the next moment no handler runs.
- KEPT_
CALLS - Calls with IDs a key remembers across compaction, at most.
- KEPT_
CALL_ MS - How long a key remembers a call’s ID and result after compaction.
- MAX_
WAITING - Calls that may wait for one key at once; more are refused as busy.
- SEND_
PREFIX - Update IDs of one-way calls (
send) start with this: their callers are answered once the call is accepted, not when it finishes. - STATE_
QUERY - The query every object answers with its committed state.
Functions§
- check_
type - Checks an object type’s name: it is the first part of its keys’ IDs.
- decode_
call encode_callback:(handler, id, argument).- decode_
delta - encode_
call - A call from workflow code, as a
Childrecord’s input: the handler, the call’s ID (made from the caller’s journal position) and the argument. - encode_
delta - One handler’s committed state changes, as its
UpdateDonecarries them: a JSON object,nullfor a cleared key. - is_
auto_ id - Whether an update ID was made up by the engine (no caller ID to keep).
- is_
object_ journal - Whether a journal is an object run’s.
- is_send
- Whether the update is a one-way call.
- key_of
- The key of an object run’s workflow ID.
- object_
id - The workflow ID of key
keyof object typewtype. - state_
json - The state as one JSON object.
- view
- An object run’s committed state and running calls from its journal
alone: the snapshot, then every recorded commit in order. No code runs.
openremoves the codec from a sealed payload.