Skip to main content

PostgresProjector

Trait PostgresProjector 

Source
pub trait PostgresProjector: Send {
    type Event: DeserializeOwned + Send + Sync;
    type Error: Error + Send + Sync + 'static;
    type AfterCommit: AfterCommit;

    // Required methods
    fn name(&self) -> &ProjectorName;
    fn apply<'a, 'c>(
        &'a mut self,
        event: &'a Self::Event,
        position: DeliveryPosition,
        tx: &'a mut Transaction<'c, Postgres>,
    ) -> impl Future<Output = Result<Self::AfterCommit, Self::Error>> + Send + 'a
       where 'c: 'a;

    // Provided methods
    fn decode(
        &self,
        envelope: &PersistedEventEnvelope,
    ) -> Result<Self::Event, BoxedProjectionError> { ... }
    fn on_error(
        &mut self,
        failure: ProjectionFailureContext<'_, Self::Error>,
    ) -> ProjectionFailureDecision { ... }
}
Expand description

Applies decoded events through the transaction owned by the PostgreSQL runner.

Required Associated Types§

Source

type Event: DeserializeOwned + Send + Sync

Decoded event contract accepted by this projection.

Source

type Error: Error + Send + Sync + 'static

Application error returned while applying an event.

Source

type AfterCommit: AfterCommit

Work deferred until the event transaction commits.

Required Methods§

Source

fn name(&self) -> &ProjectorName

Returns this projection’s stable, application-supplied name.

Source

fn apply<'a, 'c>( &'a mut self, event: &'a Self::Event, position: DeliveryPosition, tx: &'a mut Transaction<'c, Postgres>, ) -> impl Future<Output = Result<Self::AfterCommit, Self::Error>> + Send + 'a
where 'c: 'a,

Applies one event through the runner-owned read-model transaction.

Provided Methods§

Source

fn decode( &self, envelope: &PersistedEventEnvelope, ) -> Result<Self::Event, BoxedProjectionError>

Decodes a persisted envelope into this projection’s application event.

Applications own this boundary and may inspect the envelope’s persisted event type, metadata, stream identity, or other fields before decoding. The default preserves payload-only JSON decoding for existing projectors. Any error returned here is terminal and is reported as super::TransactionalProjectionError::Decode.

Source

fn on_error( &mut self, failure: ProjectionFailureContext<'_, Self::Error>, ) -> ProjectionFailureDecision

Chooses how the runner handles an application failure.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§