Skip to main content

AggregateStoreBuilder

Struct AggregateStoreBuilder 

Source
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

Source

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
§Returns

self for method chaining.

Source

pub fn process_manager<PM>(self) -> Self
where 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
§Returns

self for method chaining.

Source

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 implementing Aggregate with Command: 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.

Source

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 implementing Aggregate with Command: DeserializeOwned.
§Returns

self for method chaining.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more