pub struct EmbeddedKernelStore { /* private fields */ }Expand description
Every kernel persistence port on one local store.
The engine behind it is chosen when the data directory is created and
hidden behind the storage seam
(historical ADR-018):
SQLite for every store this binary can open. Cloning is cheap (shared
engine handle). Commits are fsync-durable, so
each successful port write survives kill -9; a crash mid-transaction
loses only the in-flight transaction.
Implementations§
Source§impl EmbeddedKernelStore
impl EmbeddedKernelStore
Sourcepub async fn migrate_data_dir<F>(
source_dir: &Path,
destination_dir: &Path,
derive: F,
) -> Result<(EmbeddedKernelStore, StoreMigrationReceipt), PortError>
pub async fn migrate_data_dir<F>( source_dir: &Path, destination_dir: &Path, derive: F, ) -> Result<(EmbeddedKernelStore, StoreMigrationReceipt), PortError>
Compatibility entry point. No current layout requires migration.
Sourcepub async fn migrate_data_dir_to<F>(
source_dir: &Path,
destination_dir: &Path,
destination_engine: StorageEngine,
_derive: F,
) -> Result<(EmbeddedKernelStore, StoreMigrationReceipt), PortError>
pub async fn migrate_data_dir_to<F>( source_dir: &Path, destination_dir: &Path, destination_engine: StorageEngine, _derive: F, ) -> Result<(EmbeddedKernelStore, StoreMigrationReceipt), PortError>
Compatibility entry point with an explicit destination engine.
Sourcepub async fn open_or_migrate_data_dir<F>(
source_dir: &Path,
destination_dir: &Path,
derive: F,
) -> Result<(EmbeddedKernelStore, Option<StoreMigrationReceipt>), PortError>
pub async fn open_or_migrate_data_dir<F>( source_dir: &Path, destination_dir: &Path, derive: F, ) -> Result<(EmbeddedKernelStore, Option<StoreMigrationReceipt>), PortError>
Reopen a completed destination or apply the compatibility migration.
Sourcepub async fn open_or_migrate_data_dir_to<F>(
source_dir: &Path,
destination_dir: &Path,
destination_engine: StorageEngine,
derive: F,
) -> Result<(EmbeddedKernelStore, Option<StoreMigrationReceipt>), PortError>
pub async fn open_or_migrate_data_dir_to<F>( source_dir: &Path, destination_dir: &Path, destination_engine: StorageEngine, derive: F, ) -> Result<(EmbeddedKernelStore, Option<StoreMigrationReceipt>), PortError>
Reopen a completed destination or apply the compatibility migration.
Sourcepub async fn migration_receipt(
&self,
) -> Result<Option<StoreMigrationReceipt>, PortError>
pub async fn migration_receipt( &self, ) -> Result<Option<StoreMigrationReceipt>, PortError>
A historical receipt stored by the migration that produced this store.
Source§impl EmbeddedKernelStore
impl EmbeddedKernelStore
Sourcepub fn export_bundle_blocking(&self) -> Result<String, PortError>
pub fn export_bundle_blocking(&self) -> Result<String, PortError>
Synchronous export for already-blocking operational paths such as
Doctor. Async application paths should use Self::export_bundle.
Sourcepub async fn export_bundle(&self) -> Result<String, PortError>
pub async fn export_bundle(&self) -> Result<String, PortError>
Serializes the full event log as a JSON-Lines bundle: one header line followed by one event per line, in sequence order.
Sourcepub async fn export_bundle_for_abouts(
&self,
requested_abouts: &[String],
) -> Result<String, PortError>
pub async fn export_bundle_for_abouts( &self, requested_abouts: &[String], ) -> Result<String, PortError>
Serializes only events rooted at one of requested_abouts.
Abouts are opaque routing identifiers: matching is exact, with no trimming, case folding, prefix expansion or other normalisation. The filtered stream keeps the store’s event order and each aggregate’s recorded revisions, then receives bundle-local positions starting at one. A missing requested about is refused before callers can create a destination file.
Sourcepub async fn export_named_bundle(
&self,
snapshot_id: &str,
) -> Result<String, PortError>
pub async fn export_named_bundle( &self, snapshot_id: &str, ) -> Result<String, PortError>
Exports the same complete stream with a human-selected snapshot id. The id is metadata, not a filename: callers may store the bundle in git, an artifact store, or anywhere else without changing what it identifies.
Sourcepub async fn import_bundle<F>(
&self,
bundle: &str,
derive: F,
) -> Result<ImportReport, PortError>
pub async fn import_bundle<F>( &self, bundle: &str, derive: F, ) -> Result<ImportReport, PortError>
Replays a bundle into this store. Fail-fast rules: the store must be empty (no merge semantics in v1 — ADR-011 rationale applies), the header must match supported formats, and every event must reproduce exactly the revision it was exported with.
Source§impl EmbeddedKernelStore
impl EmbeddedKernelStore
Sourcepub async fn rebuild_projections<F>(
&self,
derive: F,
) -> Result<ProjectionRebuildReport, PortError>
pub async fn rebuild_projections<F>( &self, derive: F, ) -> Result<ProjectionRebuildReport, PortError>
Drops every projection table and rebuilds them by replaying the event log in sequence order — the recovery and migration story in one.
The mutation derivation is injected so this adapter stays free of
application-layer dependencies; the composition root passes
kmp_application::projection_mutations_for_context_event.
The whole rebuild is one transaction: a crash mid-rebuild leaves the
previous projections intact.
Source§impl EmbeddedKernelStore
impl EmbeddedKernelStore
Sourcepub fn open(data_dir: &Path) -> Result<EmbeddedKernelStore, PortError>
pub fn open(data_dir: &Path) -> Result<EmbeddedKernelStore, PortError>
Opens (or initializes) the store inside data_dir, applying the
ADR-012 fail-fast rules before touching the engine. A fresh directory
gets the default engine; an existing one opens with the engine it was
created with.
Sourcepub fn open_with_engine(
data_dir: &Path,
engine: StorageEngine,
) -> Result<EmbeddedKernelStore, PortError>
pub fn open_with_engine( data_dir: &Path, engine: StorageEngine, ) -> Result<EmbeddedKernelStore, PortError>
open with the engine chosen: a fresh directory is
created for SQLite, and an existing one must already be engine — a
store is never reinterpreted as another engine’s.
Sourcepub fn engine_of(data_dir: &Path) -> Result<StorageEngine, PortError>
pub fn engine_of(data_dir: &Path) -> Result<StorageEngine, PortError>
The engine a data directory was created with, without opening it.
Trait Implementations§
Source§impl Clone for EmbeddedKernelStore
impl Clone for EmbeddedKernelStore
Source§fn clone(&self) -> EmbeddedKernelStore
fn clone(&self) -> EmbeddedKernelStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ContextEventStore for EmbeddedKernelStore
impl ContextEventStore for EmbeddedKernelStore
Source§async fn append(
&self,
event: ContextUpdatedEvent,
expected_revision: u64,
) -> Result<u64, PortError>
async fn append( &self, event: ContextUpdatedEvent, expected_revision: u64, ) -> Result<u64, PortError>
PortError::Conflict if
expected_revision does not match the current revision for this
(root_node_id, role) aggregate.