pub struct InMemoryEventJournal { /* private fields */ }Expand description
In-memory HarnessEventJournal backed by a per-run Vec.
Cheaply clonable through an inner Arc; clones share the same streams.
There is no durability — entries are lost when the last clone drops.
Retains at most InMemoryEventJournal::max_runs distinct run_id
streams (default DEFAULT_JOURNAL_MAX_RUNS); once exceeded, the oldest
run (by first-append order) is evicted wholesale to keep memory bounded
across long-lived processes that journal many runs.
Implementations§
Source§impl InMemoryEventJournal
impl InMemoryEventJournal
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty in-memory journal with the default run-retention
cap (DEFAULT_JOURNAL_MAX_RUNS).
Sourcepub fn with_max_runs(max_runs: usize) -> Self
pub fn with_max_runs(max_runs: usize) -> Self
Creates a new, empty in-memory journal that retains at most
max_runs distinct run_id streams, evicting the oldest (by first
append) once exceeded. 0 means unbounded.
Sourcepub fn with_max_entries_per_run(max_entries_per_run: usize) -> Self
pub fn with_max_entries_per_run(max_entries_per_run: usize) -> Self
Creates a new, empty in-memory journal that retains at most
max_entries_per_run observations within each run’s stream,
dropping the oldest once exceeded. 0 means unbounded, which is the
default.
This bounds a dimension Self::with_max_runs cannot: a single
long-lived run is one stream, so it is never evicted and its entries
grow for as long as the run does. See
DEFAULT_JOURNAL_MAX_ENTRIES_PER_RUN for the measured shape that
motivates it.
Trimming loses observations. A dropped entry is gone, and
Self::read_from will refuse an offset below what survives rather
than silently returning a short answer — so this is for a consumer that
exports as it goes and only ever reads recent offsets. A consumer that
reads the whole stream once at the end of the run must not use it.
Sourcepub fn len(&self, run_id: &str) -> usize
pub fn len(&self, run_id: &str) -> usize
Returns the number of observations stored for run_id.
Read-only accessor: a poisoned lock (a panic in another holder) is
recovered rather than propagated, matching the poisoned() mapping the
fallible trait methods use.
Trait Implementations§
Source§impl Clone for InMemoryEventJournal
impl Clone for InMemoryEventJournal
Source§fn clone(&self) -> InMemoryEventJournal
fn clone(&self) -> InMemoryEventJournal
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InMemoryEventJournal
impl Debug for InMemoryEventJournal
Source§impl Default for InMemoryEventJournal
impl Default for InMemoryEventJournal
Source§impl HarnessEventJournal for InMemoryEventJournal
impl HarnessEventJournal for InMemoryEventJournal
Source§fn append<'life0, 'async_trait>(
&'life0 self,
obs: AgentObservation,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn append<'life0, 'async_trait>(
&'life0 self,
obs: AgentObservation,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
obs to the journal and returns the offset it was stored at
within its run’s stream.Source§fn read_from<'life0, 'life1, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
offset: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentObservation>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read_from<'life0, 'life1, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
offset: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentObservation>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
run_id whose stream offset is >= offset, in offset order. Reading from 0 replays the whole run;
reading an unknown run returns an empty Vec.Source§fn read_window<'life0, 'life1, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
offset: u64,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentObservation>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read_window<'life0, 'life1, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
offset: u64,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentObservation>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
limit observations for run_id starting at offset
(a bounded replay window). The default reads from offset and
truncates; durable backends may override for a server-side limit.Source§fn read_filtered<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
offset: u64,
kinds: &'life2 [&'life3 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentObservation>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn read_filtered<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
offset: u64,
kinds: &'life2 [&'life3 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<AgentObservation>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
run_id from offset whose
AgentEvent::kind is in
kinds. An empty kinds slice matches everything. This is the
UI-surface filter (text-only, tool timeline, cost updates, errors, …).