Skip to main content

Module read_model

Module read_model 

Source
Expand description

Read Models - storage-backed projections and read-optimized views.

Relational models stage explicit row mutations:

use distributed::read_model::{ReadModelWritePlanBuilder, ReadModelWritePlanCommitExt};

let mut read_models = ReadModelWritePlanBuilder::new();
read_models.upsert(&player)?;
read_models.upsert_related(&player, "weapons", &weapon)?;
repo.read_models(read_models).commit(&mut aggregate).await?;

Persistent repositories expose the staging shape through ReadModelWritePlanCommitExt::read_models, returning a future from commit.

Distributed projectors can commit a write plan directly against a read-model adapter. Projection handlers should make those writes idempotent so bus retries can safely replay the same message:

let mut read_models = ReadModelWritePlanBuilder::new();
read_models.upsert(&view)?;
let outcome = read_models.commit(&read_store)?;

Re-exports§

pub use change::ReadModelChange;

Modules§

change
Read-model change notification seam (always compiled).

Structs§

InMemoryReadModelStore
In-memory read model store backed by a HashMap.
ReadModelIncludeRows
Rows loaded for one requested relationship include.
ReadModelLoadBuilder
Builder for one explicit primary-key read-model load over the async store traits.
ReadModelLoadGraph
Untyped graph loaded by a relational read-model adapter.
ReadModelLoadRequest
A request an adapter can satisfy with a primary-key read plus explicit includes.
ReadModelQueryCapabilities
Adapter capabilities for primary-key relational read-model loads.
ReadModelWorkspace
Store-bound read-model workspace for load, mutate, sync, commit workflows.
ReadModelWritePlanBuilder
Detached builder for read-model write plans that are applied at commit.
Versioned
A versioned wrapper around read model data for optimistic concurrency control.

Traits§

ReadModel
Trait implemented by the derive macro for read-model identity metadata.
ReadModelWorkspaceExt
Extension trait that starts a tracked read-model workspace from an async store.
RelationalReadModel
Opt-in trait for table-mapped relational read models.
RelationalReadModelIncludes
Relationship hydration hooks generated for table-mapped read models.