pub struct EmbeddedKernelStore { /* private fields */ }Expand description
Every kernel persistence port on one local redb file.
Cloning is cheap (shared database 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<(Self, StoreMigrationReceipt), PortError>
pub async fn migrate_data_dir<F>( source_dir: &Path, destination_dir: &Path, derive: F, ) -> Result<(Self, StoreMigrationReceipt), PortError>
Migrates source_dir into destination_dir and opens the result.
derive is the projection derivation the composition root owns
(kmp_application::projection_mutations_for_context_event), kept
injected so this adapter stays free of the application layer.
Sourcepub async fn open_or_migrate_data_dir<F>(
source_dir: &Path,
destination_dir: &Path,
derive: F,
) -> Result<(Self, Option<StoreMigrationReceipt>), PortError>
pub async fn open_or_migrate_data_dir<F>( source_dir: &Path, destination_dir: &Path, derive: F, ) -> Result<(Self, Option<StoreMigrationReceipt>), PortError>
Migrate once, reopen afterwards: safe to call on every start.
A destination that already holds a store is opened as it is — the migration is not repeated, and the receipt (when there is one) says where that memory came from.
Sourcepub async fn migration_receipt(
&self,
) -> Result<Option<StoreMigrationReceipt>, PortError>
pub async fn migration_receipt( &self, ) -> Result<Option<StoreMigrationReceipt>, PortError>
The receipt of the migration that produced this store, if any.
Source§impl EmbeddedKernelStore
impl EmbeddedKernelStore
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 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
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.