Skip to main content

ProcessManager

Trait ProcessManager 

Source
pub trait ProcessManager:
    Default
    + Serialize
    + DeserializeOwned
    + Send
    + Sync
    + 'static {
    const NAME: &'static str;

    // Required methods
    fn subscriptions(&self) -> &'static [&'static str];
    fn react(
        &mut self,
        aggregate_type: &str,
        stream_id: &str,
        event: &Event,
    ) -> Vec<CommandEnvelope>;
}
Expand description

A cross-aggregate workflow coordinator that reacts to events by producing commands.

Process managers subscribe to aggregate event streams (like projections) but instead of building a read model, they emit CommandEnvelopes that the store dispatches to target aggregates.

§Contract

  • react must be deterministic: given the same sequence of events, it must produce the same command envelopes.
  • Unknown event types should be silently ignored for forward compatibility.
  • State is checkpointed after all envelopes from a catch-up pass have been dispatched (or dead-lettered), ensuring crash safety via re-processing.

Required Associated Constants§

Source

const NAME: &'static str

Human-readable name, used as a directory name under process_managers/.

Required Methods§

Source

fn subscriptions(&self) -> &'static [&'static str]

The aggregate types this process manager subscribes to.

Each entry must match an Aggregate::AGGREGATE_TYPE string.

Source

fn react( &mut self, aggregate_type: &str, stream_id: &str, event: &Event, ) -> Vec<CommandEnvelope>

React to a single event from a subscribed stream.

Returns zero or more CommandEnvelopes to dispatch.

§Arguments
  • aggregate_type - Which aggregate produced the event.
  • stream_id - The specific aggregate instance.
  • event - The raw eventfold event.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§