pub struct SubscriptionBuilder<S, P, SS>where
S: EventStore,
P: ProjectionFilters,{ /* private fields */ }Expand description
Builder for configuring and starting a subscription.
Created via Repository::subscribe(). Use on_update() to register
callbacks, then call start() to begin processing events.
Implementations§
Source§impl<S, P, SS> SubscriptionBuilder<S, P, SS>where
S: SubscribableStore + Clone + Send + Sync + 'static,
S::Position: Ord + Send + Sync,
S::Data: Send,
S::Metadata: Send + Sync,
P: Projection + ProjectionFilters<Id = S::Id, Metadata = S::Metadata> + Serialize + DeserializeOwned + Send + Sync + 'static,
P::InstanceId: Clone + Send + Sync + 'static,
P::Metadata: Send,
SS: SnapshotStore<P::InstanceId, Position = S::Position> + Send + Sync + 'static,
impl<S, P, SS> SubscriptionBuilder<S, P, SS>where
S: SubscribableStore + Clone + Send + Sync + 'static,
S::Position: Ord + Send + Sync,
S::Data: Send,
S::Metadata: Send + Sync,
P: Projection + ProjectionFilters<Id = S::Id, Metadata = S::Metadata> + Serialize + DeserializeOwned + Send + Sync + 'static,
P::InstanceId: Clone + Send + Sync + 'static,
P::Metadata: Send,
SS: SnapshotStore<P::InstanceId, Position = S::Position> + Send + Sync + 'static,
Sourcepub fn on_update<F>(self, callback: F) -> Self
pub fn on_update<F>(self, callback: F) -> Self
Register a callback invoked after each event is applied.
Callbacks must complete quickly. Long-running work should be dispatched to a separate task via a channel. Blocking the callback stalls the subscription loop and delays event processing.
Sourcepub async fn start(
self,
) -> Result<SubscriptionHandle<S::Error>, SubscriptionError<S::Error>>
pub async fn start( self, ) -> Result<SubscriptionHandle<S::Error>, SubscriptionError<S::Error>>
Start the subscription.
This method returns only after catch-up completes.
Spawns a background task that:
- Loads the most recent snapshot (if available)
- Subscribes to the event stream from the snapshot position
- Replays historical events (catch-up phase)
- Waits until catch-up is complete
- Continues processing live events and firing
on_update
§Errors
Returns an error if the initial snapshot load or stream setup fails.
Auto Trait Implementations§
impl<S, P, SS> Freeze for SubscriptionBuilder<S, P, SS>
impl<S, P, SS> !RefUnwindSafe for SubscriptionBuilder<S, P, SS>
impl<S, P, SS> Send for SubscriptionBuilder<S, P, SS>
impl<S, P, SS> Sync for SubscriptionBuilder<S, P, SS>
impl<S, P, SS> Unpin for SubscriptionBuilder<S, P, SS>
impl<S, P, SS> !UnwindSafe for SubscriptionBuilder<S, P, SS>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more