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§
Sourcetype Event: DeserializeOwned + Send + Sync
type Event: DeserializeOwned + Send + Sync
Decoded event contract accepted by this projection.
Sourcetype AfterCommit: AfterCommit
type AfterCommit: AfterCommit
Work deferred until the event transaction commits.
Required Methods§
Sourcefn name(&self) -> &ProjectorName
fn name(&self) -> &ProjectorName
Returns this projection’s stable, application-supplied name.
Sourcefn 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 + 'awhere
'c: 'a,
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 + 'awhere
'c: 'a,
Applies one event through the runner-owned read-model transaction.
Provided Methods§
Sourcefn decode(
&self,
envelope: &PersistedEventEnvelope,
) -> Result<Self::Event, BoxedProjectionError>
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.
Sourcefn on_error(
&mut self,
failure: ProjectionFailureContext<'_, Self::Error>,
) -> ProjectionFailureDecision
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".