pub struct Engine {
state: RwLock<State>,
stats: EngineStats,
}Expand description
Fields§
§state: RwLock<State>§stats: EngineStatsImplementations§
Source§impl Engine
impl Engine
Sourcepub fn stats(&self) -> &EngineStats
pub fn stats(&self) -> &EngineStats
Process-lifetime counters. Survives Self::drop_adapter.
Sourcepub async fn subscribe(
&self,
adapter_id: impl Into<AdapterId>,
sub_id: impl Into<SubId>,
route: RouteKey,
tx: Sender<Delivery>,
) -> Result<SubscriberKey, EngineError>
pub async fn subscribe( &self, adapter_id: impl Into<AdapterId>, sub_id: impl Into<SubId>, route: RouteKey, tx: Sender<Delivery>, ) -> Result<SubscriberKey, EngineError>
Registers a subscriber. The adapter owns tx and reads Deliverys.
A RouteKey with type_hint: None is a wildcard: every type on
that topic. A typed key matches only that hint. The same sub_id
may be reused on a different adapter.
§Errors
Returns EngineError::DuplicateSub if this adapter already
registered sub_id.
Sourcepub async fn unsubscribe(
&self,
adapter_id: impl Into<AdapterId>,
sub_id: impl Into<SubId>,
) -> Result<(), EngineError>
pub async fn unsubscribe( &self, adapter_id: impl Into<AdapterId>, sub_id: impl Into<SubId>, ) -> Result<(), EngineError>
Removes one subscription. Further publishes will not reach it.
§Errors
Returns EngineError::UnknownSub if this adapter has no
subscription with that sub_id.
Sourcepub async fn drop_adapter(&self, adapter_id: impl Into<AdapterId>) -> usize
pub async fn drop_adapter(&self, adapter_id: impl Into<AdapterId>) -> usize
Removes every subscription owned by adapter_id.
Returns how many were removed, or 0 if the adapter had none.
Call this on shutdown and when a session restarts, or stale
subscriptions keep matching and silently discarding messages.
Sourcepub async fn publish(&self, envelope: Envelope) -> PublishOutcome
pub async fn publish(&self, envelope: Envelope) -> PublishOutcome
Fans out envelope to matching subscribers. Never inspects the payload.
Matching is exact-plus-wildcard: a publish with
type_hint: Some("Ping") reaches both typed(topic, "Ping") and
topic(topic) subscribers. A publish with no type hint reaches
wildcards only.
Each send is try_send. A full or closed channel counts as
dropped and does not block other subscribers.
Sourcepub async fn subscription_count(&self) -> usize
pub async fn subscription_count(&self) -> usize
Number of registered subscriptions across every adapter.
Used to wait until a newly spawned adapter has subscribed before publishing test traffic. Not a readiness API for production.