Skip to main content

SubscriptionDef

Trait SubscriptionDef 

Source
pub trait SubscriptionDef<P>:
    Send
    + Sync
    + 'static
where P: Serialize + DeserializeOwned + Send + Sync + 'static + Unpin,
{ type Key: Serialize + DeserializeOwned + Display + FromStr + Clone + Send + Sync + 'static; type InstanceConfig: Serialize + DeserializeOwned + Send + Sync + 'static; type Subscriber: KeyedSubscriber<P>; // Required methods fn wake_keys( &self, event: &PersistentOutboxEvent<P>, ) -> impl IntoIterator<Item = WakeKey>; fn instantiate( &self, key: Self::Key, cfg: Self::InstanceConfig, ) -> Self::Subscriber; }
Expand description

The definition of one keyed-subscriber type: pure classification plus a factory. NO async, NO DB deps — everything here is cheap and synchronous, called on every wake, pause expiry and retry (see KeyedSubscriber’s factory contract on instantiate).

Required Associated Types§

Source

type Key: Serialize + DeserializeOwned + Display + FromStr + Clone + Send + Sync + 'static

The domain key identifying one subscription instance (e.g. a webhook endpoint id). Display/FromStr round-trip it through the subscriptions table and the job crate’s string-keyed storage.

Source

type InstanceConfig: Serialize + DeserializeOwned + Send + Sync + 'static

Immutable per-instance configuration, persisted alongside the key (e.g. the endpoint’s owning partner id).

Source

type Subscriber: KeyedSubscriber<P>

Required Methods§

Source

fn wake_keys( &self, event: &PersistentOutboxEvent<P>, ) -> impl IntoIterator<Item = WakeKey>

Which partition(s) of the stream this event belongs to — i.e. which subscriptions must be awake to see it. Empty = this event wakes nobody of this type; there is no separate interest prefilter, an empty return IS no-interest.

This decides wakes, never delivery: a woken member reads the whole stream from its cursor and filters in handle. Over-approximating costs an empty run; under-approximating leaves a passivated member unwoken with its events unread, so it must never miss an event a live subscription would act on.

Source

fn instantiate( &self, key: Self::Key, cfg: Self::InstanceConfig, ) -> Self::Subscriber

Build the subscriber instance for one run. Called fresh on every run — every wake, every pause expiry, every retry, on any node — so this must be cheap and the subscriber must be stateless between runs: durable state is the cursor plus whatever the subscriber’s own entities record, never anything held in the instance itself.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§