pub struct AggregateStoreBuilder { /* private fields */ }Expand description
Builder for configuring an AggregateStore with projections and
process managers.
Created via AggregateStore::builder. Register projections with
projection, process managers with
process_manager, and dispatch
targets with aggregate_type,
then call open to finalize.
§Examples
use eventfold_es::AggregateStore;
let store = AggregateStore::builder("/tmp/my-app")
// .projection::<MyProjection>()
// .process_manager::<MySaga>()
// .aggregate_type::<MyAggregate>()
.open()
.await?;Implementations§
Source§impl AggregateStoreBuilder
impl AggregateStoreBuilder
Sourcepub fn projection<P: Projection>(self) -> Self
pub fn projection<P: Projection>(self) -> Self
Register a projection type to be managed by this store.
The projection will be initialized (loading any existing checkpoint)
when open is called.
§Type Parameters
P- A type implementingProjection.
§Returns
self for method chaining.
Sourcepub fn process_manager<PM>(self) -> Selfwhere
PM: ProcessManager,
pub fn process_manager<PM>(self) -> Selfwhere
PM: ProcessManager,
Register a process manager type to be managed by this store.
The process manager will be initialized (loading any existing
checkpoint) when open is called.
Use run_process_managers
to trigger catch-up and dispatch.
§Type Parameters
PM- A type implementingProcessManager.
§Returns
self for method chaining.
Sourcepub fn idle_timeout(self, timeout: Duration) -> Self
pub fn idle_timeout(self, timeout: Duration) -> Self
Register an aggregate type as a dispatch target for process managers.
This allows CommandEnvelopes
targeting this aggregate type to be deserialized and routed. The
aggregate’s Command type must implement DeserializeOwned.
§Type Parameters
A- A type implementingAggregatewithCommand: DeserializeOwned.
§Returns
self for method chaining.
Set the idle timeout for actor eviction.
Actors that receive no messages for this duration will shut down,
releasing their file lock. The next get call
transparently re-spawns the actor and recovers state from disk.
Defaults to 5 minutes. Pass Duration::from_secs(u64::MAX / 2) to
effectively disable idle eviction.
§Arguments
timeout- How long an idle actor waits before shutting down.
§Returns
self for method chaining.
Sourcepub fn aggregate_type<A>(self) -> Self
pub fn aggregate_type<A>(self) -> Self
Register an aggregate type as a dispatch target for process managers.
This allows CommandEnvelopes
targeting this aggregate type to be deserialized and routed. The
aggregate’s Command type must implement DeserializeOwned.
§Type Parameters
A- A type implementingAggregatewithCommand: DeserializeOwned.
§Returns
self for method chaining.
Sourcepub async fn open(self) -> Result<AggregateStore>
pub async fn open(self) -> Result<AggregateStore>
Build and open the store, initializing all registered projections and process managers.
Creates the metadata directory on disk and instantiates each projection runner and process manager runner (loading persisted checkpoints if available).
§Returns
A fully initialized AggregateStore.
§Errors
Returns io::Error if directory creation or initialization fails.