Skip to main content

Module subscription

Module subscription 

Source
Expand description

Push-based projection subscriptions.

This module provides continuous event subscriptions that keep projections up-to-date as events are committed. Unlike Repository::load_projection, which rebuilds a projection from scratch on each call, subscriptions maintain an in-memory projection that updates in real time.

§Overview

A subscription:

  1. Replays historical events (catch-up phase)
  2. Transitions to processing live events as they are committed
  3. Fires callbacks on each update

§Example

let subscription = repository
    .subscribe::<Dashboard>(())
    .on_update(|dashboard| println!("{dashboard:?}"))
    .start()
    .await?;

// Later, shut down gracefully
subscription.stop().await?;

Structs§

SubscriptionBuilder
Builder for configuring and starting a subscription.
SubscriptionHandle
Handle to a running subscription.

Enums§

SubscriptionError
Errors that can occur during subscription lifecycle.

Traits§

SubscribableStore
A store that supports push-based event subscriptions.

Type Aliases§

EventStream
Type alias for the boxed event stream returned by SubscribableStore::subscribe.