pub struct EventStateLog<Event: Copy + 'static, State: Copy + 'static> { /* private fields */ }Implementations§
Source§impl<Event: Copy + 'static, State: Copy + 'static> EventStateLog<Event, State>
impl<Event: Copy + 'static, State: Copy + 'static> EventStateLog<Event, State>
pub fn create( base_path: impl AsRef<Path>, ring_capacity: usize, initial_state: State, ) -> Result<Self, EventLogError>
pub fn open( base_path: impl AsRef<Path>, ring_capacity: usize, ) -> Result<Self, EventLogError>
Sourcepub fn emit(&self, event: Event) -> Result<(), EventLogError>
pub fn emit(&self, event: Event) -> Result<(), EventLogError>
Push an event onto the durable log. Returns Err(Ring(Full))
when the ring is full; callers should drain or apply
backpressure.
Sourcepub fn drain_and_fold<F: FnMut(&mut State, &Event)>(&self, fold: F) -> usize
pub fn drain_and_fold<F: FnMut(&mut State, &Event)>(&self, fold: F) -> usize
Drain all pending events from the log and apply each to the
current state via fold. The state cell is updated after
all events are folded. Returns the number of events applied.
Sourcepub fn read_current(&self) -> State
pub fn read_current(&self) -> State
Read the current materialized state. O(1) - one SeqLock cell read.
Sourcepub fn pending_events(&self) -> usize
pub fn pending_events(&self) -> usize
Approximate number of events waiting in the log.
Sourcepub fn set_state(&self, state: State)
pub fn set_state(&self, state: State)
Force-set the materialized state (e.g., for checkpoint restore).
Sourcepub fn flush(&self) -> Result<(), EventLogError>
pub fn flush(&self) -> Result<(), EventLogError>
Sync both files to disk.
Sourcepub fn flush_async(&self) -> Result<(), EventLogError>
pub fn flush_async(&self) -> Result<(), EventLogError>
Non-blocking flush of both files. Delegates to the ring and the state cell’s flush_async. Note: Windows is only partially async (sync to page cache, not to disk).
Trait Implementations§
Source§impl<Event: Copy + Send + Sync + 'static, State: Copy + Send + Sync + 'static> AdaptiveInstance for EventStateLog<Event, State>
impl<Event: Copy + Send + Sync + 'static, State: Copy + Send + Sync + 'static> AdaptiveInstance for EventStateLog<Event, State>
fn header(&self) -> &HandshakeHeader
fn ring(&self) -> &ObservationRing
fn make_policy(&self) -> Box<dyn Policy>
Source§fn apply_migration(&self, new_tag: u32)
fn apply_migration(&self, new_tag: u32)
Called by the sidecar when the policy returns a new strategy
tag. Default implementation: just set the tag on the header.
Primitives that need heavier migration (data-layout swap)
override this to perform the swap before (or after) updating
the tag.
Auto Trait Implementations§
impl<Event, State> !Freeze for EventStateLog<Event, State>
impl<Event, State> !RefUnwindSafe for EventStateLog<Event, State>
impl<Event, State> !UnwindSafe for EventStateLog<Event, State>
impl<Event, State> Send for EventStateLog<Event, State>
impl<Event, State> Sync for EventStateLog<Event, State>
impl<Event, State> Unpin for EventStateLog<Event, State>
impl<Event, State> UnsafeUnpin for EventStateLog<Event, State>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more