pub trait EventSourcedExt: Sized {
    // Provided method
    async fn spawn<L, S, B>(
        id: Self::Id,
        snapshot_after: Option<NonZeroU64>,
        cmd_buffer: NonZeroUsize,
        evt_log: L,
        snapshot_store: S,
        binarize: B
    ) -> Result<EntityRef<Self>, SpawnError>
       where Self: EventSourced,
             L: EvtLog<Id = Self::Id>,
             S: SnapshotStore<Id = Self::Id>,
             B: Binarize<Self::Evt, Self::State> { ... }
}
Expand description

Extension methods for types implementing EventSourced.

Provided Methods§

source

async fn spawn<L, S, B>( id: Self::Id, snapshot_after: Option<NonZeroU64>, cmd_buffer: NonZeroUsize, evt_log: L, snapshot_store: S, binarize: B ) -> Result<EntityRef<Self>, SpawnError>
where Self: EventSourced, L: EvtLog<Id = Self::Id>, S: SnapshotStore<Id = Self::Id>, B: Binarize<Self::Evt, Self::State>,

Spawns an event sourced entity and creates an EntityRef as a handle for it.

First the given SnapshotStore is used to find and possibly load a snapshot. Then the EvtLog is used to find the last sequence number and then to load any remaining events.

Commands can be passed to the spawned entity by invoking handle_cmd on the returned EntityRef which uses a buffered channel with the given size.

Commands are handled by the command handler of the spawned entity. They can be rejected by returning an error. Valid commands produce an event which gets persisted to the EvtLog and then applied to the event handler of the respective entity. Snapshots can be taken to speed up future spawning.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<E> EventSourcedExt for E
where E: EventSourced,