nodestep.state.integrations.inmemory ¶
InMemoryStateStore, which keeps each thread's history in memory.
See State stores.
InMemoryStateStore¶
Thread-safe state store that keeps history in memory.
events | list[HistoryEvent] |
All stored events. |
checkpoints | list[CheckpointRecord] |
All stored checkpoints. |
Methods
async append_event(event)¶
Store an event as given.
async append_event(event)¶async append_event(event) -> HistoryEvent
event | HistoryEvent | |
HistoryEvent |
The same event. |
async append_next_event(event)¶
Store an event with the next sequence number of its thread.
async append_next_event(event)¶async append_next_event(event) -> HistoryEvent
event | HistoryEvent |
Event whose |
HistoryEvent |
The stored event with its sequence number. |
async save_checkpoint(checkpoint)¶
Store a state snapshot.
async save_checkpoint(checkpoint)¶async save_checkpoint(checkpoint) -> CheckpointRecord
checkpoint | CheckpointRecord | |
CheckpointRecord |
The same checkpoint. |
async get_history(thread_id, branch_id)¶
Return the events and checkpoints of a thread branch.
async get_history(thread_id, branch_id)¶async latest_checkpoint(thread_id, branch_id, at)¶
Return the latest checkpoint, optionally at or before an event.
async latest_checkpoint(thread_id, branch_id, at)¶async latest_checkpoint(thread_id, branch_id='main', at=None) -> CheckpointRecord | None
thread_id | str | |
branch_id | str |
Branch to read; |
at | str | None |
Event id; only checkpoints up to that event count. |
CheckpointRecord or None |
|
StateUpdateError |
If |
async fork(thread_id, ...)¶
Record a new branch starting at an event.
async fork(thread_id, ...)¶async fork(thread_id, *, from_, branch_id='main', name=None) -> BranchRecord
thread_id | str | |
from_ | str |
Event id to branch from. |
branch_id | str |
Branch to fork; |
name | str | None |
Id of the new branch; a random id when omitted. |
StateStoreError |
If the thread already has a branch with that id, including
|
async list_branches(thread_id)¶
Return the branches forked from a thread, oldest first.
async list_branches(thread_id)¶async list_branches(thread_id) -> list[BranchRecord]
thread_id | str | |
list[BranchRecord] |
Every recorded fork of the thread; |