pub struct BusClient { /* private fields */ }Expand description
A module’s current connection and the task that maintains its credentials.
Implementations§
Source§impl BusClient
impl BusClient
Sourcepub async fn connect(
subc: Arc<SubcConsumer>,
opts: BusClientOptions,
) -> Result<Self>
pub async fn connect( subc: Arc<SubcConsumer>, opts: BusClientOptions, ) -> Result<Self>
Issues a credential for the module identity that the subc daemon authenticates from the module’s launch nonce.
Sourcepub fn connection(&self) -> NatsConnection
pub fn connection(&self) -> NatsConnection
Returns a snapshot. A re-issue does not change an already held snapshot.
Sourcepub fn connection_changes(&self) -> Receiver<u64>
pub fn connection_changes(&self) -> Receiver<u64>
Changes only after a replacement connection with a new inbox is ready.
Reopen raw subscriptions and durable pulls when this receiver changes;
EventReader handles its own rebinding automatically.
If credential maintenance can no longer renew or re-issue, its task ends
and drops the sender. The receiver’s changed() then returns Err once
any unseen change has been consumed. Reconnect with BusClient::connect
or report the module as degraded when the change stream closes.
pub fn acct(&self) -> &str
Sourcepub async fn event_reader(&self, durable: &str) -> Result<EventReader>
pub async fn event_reader(&self, durable: &str) -> Result<EventReader>
Attaches to an existing EVENT durable owned by this module.
ck-bus provisions durables; this method never creates or changes one.
The name must follow bus-naming’s m_{module}[_suffix] owner rule.
The reader rebinds automatically after credential re-issue. Nothing is
acknowledged automatically: commit your own transaction before ack().
Sourcepub async fn publish_event(
&self,
event: &str,
version: u32,
qualifier: Option<&str>,
msg_id: &str,
body: impl Into<Bytes>,
) -> Result<PublishReceipt>
pub async fn publish_event( &self, event: &str, version: u32, qualifier: Option<&str>, msg_id: &str, body: impl Into<Bytes>, ) -> Result<PublishReceipt>
Stores an event using the fact’s own id for JetStream deduplication.
Event bodies carry ids, counters and enums, not large content. Bodies larger than 4 KiB are refused; retrieve large content through its owner’s own call instead.