Skip to main content

KeyedSubscriber

Trait KeyedSubscriber 

Source
pub trait KeyedSubscriber<P>:
    Send
    + Sync
    + 'static
where P: Serialize + DeserializeOwned + Send + Sync + 'static + Unpin,
{ type Batch: Default + Send + 'static; // Required method fn handle<'inv>( &self, ctx: KeyedEventCtx<'inv, Self::Batch>, event: &Arc<PersistentOutboxEvent<P>>, ) -> impl Future<Output = Result<Handled<'inv>, Box<dyn Error + Send + Sync>>> + Send; // Provided methods fn handle_undecodable( &self, error: &UndecodableEventError, ) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send { ... } fn flush( &self, op: &mut FlushOp<'_>, items: Self::Batch, ) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send { ... } }
Expand description

Keyed subscribers — persistent-only by construction: there is no handle_ephemeral and no SUBSCRIPTION selector.

That is the other side of the presence contract. A keyed subscriber is not always present — it passivates when idle, waits out pauses, and for a not-yet-subscribed key does not exist at all — so it cannot be offered unreplayable events. What it gets in exchange is everything presence forbids a SingletonSubscriber: pause_until and staged chains across external I/O.

A single-instance flow that needs those is persistent-only by definition — host it here with one static key rather than reaching for a paused singleton.

Required Associated Types§

Source

type Batch: Default + Send + 'static

Accumulator for events resolved via collect_with — see SingletonSubscriber::Batch.

Required Methods§

Source

fn handle<'inv>( &self, ctx: KeyedEventCtx<'inv, Self::Batch>, event: &Arc<PersistentOutboxEvent<P>>, ) -> impl Future<Output = Result<Handled<'inv>, Box<dyn Error + Send + Sync>>> + Send

The event arrives as the shared Arc the outbox decoded once and broadcast to every subscriber — see SingletonSubscriber::handle_persistent.

Provided Methods§

Source

fn handle_undecodable( &self, error: &UndecodableEventError, ) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send

Same default and semantics as SingletonSubscriber::handle_undecodable: fails with the error as-is, parking the cursor before the poison event.

Source

fn flush( &self, op: &mut FlushOp<'_>, items: Self::Batch, ) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send

Same contract as SingletonSubscriber::flush.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§