pub struct HookBus { /* private fields */ }Expand description
Cloneable bounded event bus shared by a host and its plugins.
Delivery is best-effort. A slow subscriber receives
HookRecvError::Lagged and must resynchronize from crate::VaultApi.
Implementations§
Source§impl HookBus
impl HookBus
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a bus with a fixed per-subscriber ring-buffer capacity.
A zero capacity is promoted to one.
Sourcepub fn epoch(&self) -> &str
pub fn epoch(&self) -> &str
Return this bus run’s identifier.
Freshly generated per bus, so it differs on every host start. The feed
is in-memory: it has no history from before this run and its sequence
numbering is meaningless outside it. The epoch is what makes that
detectable rather than silent — see EventCursor.
Opaque and unordered; compare for equality only.
Sourcepub fn lifecycle(&self) -> HookLifecycle
pub fn lifecycle(&self) -> HookLifecycle
Return whether new events are accepted.
Sourcepub fn subscribe(&self) -> Result<HookSubscription, PublishError>
pub fn subscribe(&self) -> Result<HookSubscription, PublishError>
Subscribe to future events.
Sourcepub fn publish(
&self,
vault: impl Into<String>,
event: HookEvent,
content_hash: Option<String>,
plugin_id: Option<String>,
attribution: EventAttribution,
) -> Result<VaultEventEnvelope, PublishError>
pub fn publish( &self, vault: impl Into<String>, event: HookEvent, content_hash: Option<String>, plugin_id: Option<String>, attribution: EventAttribution, ) -> Result<VaultEventEnvelope, PublishError>
Sequence and publish an advisory event.
Success does not imply that a subscriber exists. plugin_id is the
host’s own attribution of the writer and must never be taken from
caller-supplied data.
The sender mutex is held across both the sequence increment and the enqueue, so two concurrent publishes cannot be delivered out of sequence order.