Skip to main content

EventStoreLifecycle

Struct EventStoreLifecycle 

Source
pub struct EventStoreLifecycle { /* private fields */ }
Expand description

Kernel-facing wrapper that bundles every event-store concern: predecessor recovery, the open run, the halt signal, and the seal-on-drop fail-safe.

One instance is typically owned by nautilus_system::NautilusKernel via the KernelEventStoreTrait seam: the kernel calls EventStoreLifecycle::open from start(), EventStoreLifecycle::seal from finalize_stop() / dispose(), and the wrapper’s Drop runs as the last-chance seal site for callers that skip both teardown paths (e.g. imperative engine.run(...) followed by drop in BacktestEngine).

Implementations§

Source§

impl EventStoreLifecycle

Source

pub fn boot( config: Option<EventStoreConfig>, instance_id: UUID4, clock: Rc<RefCell<dyn Clock>>, ) -> Result<Self>

Boots the wrapper at kernel construction time.

Runs the predecessor recovery sweep against <base_dir>/<instance_id>/. When config is None the wrapper is inert: every method becomes a no-op.

§Errors

Returns the underlying EventStoreError when the recovery sweep fails for a reason other than the expected CrashedPredecessor handshake.

Source

pub fn boot_with_options( config: Option<EventStoreConfig>, instance_id: UUID4, clock: Rc<RefCell<dyn Clock>>, options: EventStoreLifecycleOptions, ) -> Result<Self>

Boots the wrapper at kernel construction time with process-local lifecycle options.

EventStoreConfig remains serializable. options carries runtime-only construction policy for the encoder registry and backend opener.

§Errors

Returns the underlying EventStoreError when the recovery sweep fails for a reason other than the expected CrashedPredecessor handshake.

Source

pub fn open( &mut self, instance_id: UUID4, components: &RegisteredComponents, environment: Environment, ) -> Result<(), KernelError>

Opens a fresh run on kernel start(). Idempotent against reset/rerun: a leftover session from a prior start() is sealed before a new one opens, so RunStarted remains the first entry of every run.

components is the manifest captured into the RunStarted payload. environment selects the static (backtest) or realtime (live) clock used to stamp ts_publish inside the writer.

Returns without effect when no event-store config was supplied.

§Errors

Returns KernelError::EventStoreBoot when opening the new run, spawning the writer, or blocking on the RunStarted ack fails.

Source

pub fn restore_parent_cache( &self, instance_id: UUID4, cache: &mut Cache, ) -> Result<Option<CacheReplayReport>, KernelError>

Restores cache state from the configured replay run or recovered parent run.

This is a bootstrap-only reconstruction path. It opens the sealed replay source for read-only replay, restores the cache-owned snapshot blob, then replays only the entries after the snapshot anchor directly into Cache.

§Errors

Returns KernelError::CacheReplay when the source reader, snapshot restore, decode, or cache apply step fails.

Source

pub fn seal(&mut self, ts_init: UnixNanos)

Seals the open session by writing RunEnded and updating the manifest to Ended. Idempotent: a closed or absent session makes this a no-op. Halted sessions skip the close (the recovery sweep on next boot owns the seal).

Source

pub fn recovered(&self) -> &[RecoveredRun]

Returns the recovery report from the boot sweep.

Source

pub fn parent_run_id(&self) -> Option<&str>

Returns the configured replay source or recovered parent run id, when present.

Source

pub fn is_event_store_replay_configured(&self) -> bool

Returns whether this lifecycle is configured for event-store-only replay.

Source

pub fn run_id(&self) -> Option<&str>

Returns the run id of the open session, when capture is active.

Source

pub fn snapshot_anchorer(&self) -> Option<SnapshotAnchorer>

Returns a snapshot anchorer for the open run, when capture is active.

Source

pub fn is_halted(&self) -> bool

Returns whether the writer has signaled fail-stop.

Source

pub fn halt_reason(&self) -> Option<HaltReason>

Returns the HaltReason recorded on the first fail-stop, if any.

Source

pub fn check_halt(&self) -> Option<KernelError>

Surfaces the current halt as a typed KernelError, or None when the writer has not halted.

Trait Implementations§

Source§

impl Debug for EventStoreLifecycle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for EventStoreLifecycle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl KernelEventStore for EventStoreLifecycle

Source§

fn restore_parent_cache( &mut self, instance_id: UUID4, cache: &mut Cache, ) -> Result<()>

Restores cache state from a configured replay source or recovered parent run. Read more
Source§

fn open( &mut self, instance_id: UUID4, components: &RegisteredComponents, environment: Environment, ) -> Result<()>

Opens a fresh run for the current kernel session. Read more
Source§

fn snapshot_anchorer(&self) -> Option<SnapshotAnchorer>

Returns a snapshot anchorer for the currently open run, when capture is active. Read more
Source§

fn seal(&mut self, ts_init: UnixNanos)

Seals the open run by writing the terminal entry and updating the manifest. Read more
Source§

fn run_id(&self) -> Option<&str>

Returns the run id of the currently open run, when capture is active.
Source§

fn parent_run_id(&self) -> Option<&str>

Returns the configured replay source or recovered parent run id, when present.
Source§

fn is_event_store_replay_configured(&self) -> bool

Returns whether the current config enables event-store replay. Read more
Source§

fn is_halted(&self) -> bool

Returns whether the implementation has signaled a fail-stop condition.

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V