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
impl EventStoreLifecycle
Sourcepub fn boot(
config: Option<EventStoreConfig>,
instance_id: UUID4,
clock: Rc<RefCell<dyn Clock>>,
) -> Result<Self>
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.
Sourcepub fn boot_with_options(
config: Option<EventStoreConfig>,
instance_id: UUID4,
clock: Rc<RefCell<dyn Clock>>,
options: EventStoreLifecycleOptions,
) -> Result<Self>
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.
Sourcepub fn open(
&mut self,
instance_id: UUID4,
components: &RegisteredComponents,
environment: Environment,
) -> Result<(), KernelError>
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.
Sourcepub fn restore_parent_cache(
&self,
instance_id: UUID4,
cache: &mut Cache,
) -> Result<Option<CacheReplayReport>, KernelError>
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.
Sourcepub fn seal(&mut self, ts_init: UnixNanos)
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).
Sourcepub fn recovered(&self) -> &[RecoveredRun]
pub fn recovered(&self) -> &[RecoveredRun]
Returns the recovery report from the boot sweep.
Sourcepub fn parent_run_id(&self) -> Option<&str>
pub fn parent_run_id(&self) -> Option<&str>
Returns the configured replay source or recovered parent run id, when present.
Sourcepub fn is_event_store_replay_configured(&self) -> bool
pub fn is_event_store_replay_configured(&self) -> bool
Returns whether this lifecycle is configured for event-store-only replay.
Sourcepub fn run_id(&self) -> Option<&str>
pub fn run_id(&self) -> Option<&str>
Returns the run id of the open session, when capture is active.
Sourcepub fn snapshot_anchorer(&self) -> Option<SnapshotAnchorer>
pub fn snapshot_anchorer(&self) -> Option<SnapshotAnchorer>
Returns a snapshot anchorer for the open run, when capture is active.
Sourcepub fn halt_reason(&self) -> Option<HaltReason>
pub fn halt_reason(&self) -> Option<HaltReason>
Returns the HaltReason recorded on the first fail-stop, if any.
Sourcepub fn check_halt(&self) -> Option<KernelError>
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
impl Debug for EventStoreLifecycle
Source§impl Drop for EventStoreLifecycle
impl Drop for EventStoreLifecycle
Source§impl KernelEventStore for EventStoreLifecycle
impl KernelEventStore for EventStoreLifecycle
Source§fn restore_parent_cache(
&mut self,
instance_id: UUID4,
cache: &mut Cache,
) -> Result<()>
fn restore_parent_cache( &mut self, instance_id: UUID4, cache: &mut Cache, ) -> Result<()>
Source§fn open(
&mut self,
instance_id: UUID4,
components: &RegisteredComponents,
environment: Environment,
) -> Result<()>
fn open( &mut self, instance_id: UUID4, components: &RegisteredComponents, environment: Environment, ) -> Result<()>
Source§fn snapshot_anchorer(&self) -> Option<SnapshotAnchorer>
fn snapshot_anchorer(&self) -> Option<SnapshotAnchorer>
Source§fn seal(&mut self, ts_init: UnixNanos)
fn seal(&mut self, ts_init: UnixNanos)
Source§fn run_id(&self) -> Option<&str>
fn run_id(&self) -> Option<&str>
Source§fn parent_run_id(&self) -> Option<&str>
fn parent_run_id(&self) -> Option<&str>
Source§fn is_event_store_replay_configured(&self) -> bool
fn is_event_store_replay_configured(&self) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for EventStoreLifecycle
impl !Send for EventStoreLifecycle
impl !Sync for EventStoreLifecycle
impl !UnwindSafe for EventStoreLifecycle
impl Freeze for EventStoreLifecycle
impl Unpin for EventStoreLifecycle
impl UnsafeUnpin for EventStoreLifecycle
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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