Skip to main content

EventStateLog

Struct EventStateLog 

Source
pub struct EventStateLog<Event: Copy + 'static, State: Copy + 'static> { /* private fields */ }

Implementations§

Source§

impl<Event: Copy + 'static, State: Copy + 'static> EventStateLog<Event, State>

Source

pub fn create( base_path: impl AsRef<Path>, ring_capacity: usize, initial_state: State, ) -> Result<Self, EventLogError>

Source

pub fn open( base_path: impl AsRef<Path>, ring_capacity: usize, ) -> Result<Self, EventLogError>

Source

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.

Source

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.

Source

pub fn read_current(&self) -> State

Read the current materialized state. O(1) - one SeqLock cell read.

Source

pub fn pending_events(&self) -> usize

Approximate number of events waiting in the log.

Source

pub fn set_state(&self, state: State)

Force-set the materialized state (e.g., for checkpoint restore).

Source

pub fn flush(&self) -> Result<(), EventLogError>

Sync both files to disk.

Source

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>

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

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>
where Arc<SharedCell<State>>: Send, PhantomData<Event>: Send,

§

impl<Event, State> Sync for EventStateLog<Event, State>
where Arc<SharedCell<State>>: Sync, PhantomData<Event>: Sync,

§

impl<Event, State> Unpin for EventStateLog<Event, State>
where Arc<SharedCell<State>>: Unpin, PhantomData<Event>: Unpin,

§

impl<Event, State> UnsafeUnpin for EventStateLog<Event, State>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.