pub trait KeyedSubscriber<P>:
Send
+ Sync
+ 'static{
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§
Sourcetype Batch: Default + Send + 'static
type Batch: Default + Send + 'static
Accumulator for events resolved via
collect_with — see
SingletonSubscriber::Batch.
Required Methods§
Sourcefn handle<'inv>(
&self,
ctx: KeyedEventCtx<'inv, Self::Batch>,
event: &Arc<PersistentOutboxEvent<P>>,
) -> impl Future<Output = Result<Handled<'inv>, Box<dyn Error + Send + Sync>>> + Send
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§
Sourcefn handle_undecodable(
&self,
error: &UndecodableEventError,
) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".