pub struct HubClient { /* private fields */ }Expand description
A module’s separate federation-account connection to the hub.
Opening a crate::BusClient does not request a hub credential. Open a
HubClient only when the module needs the hub. Dropping it stops its
credential maintenance without affecting the box connection.
Implementations§
Source§impl HubClient
impl HubClient
Sourcepub async fn connect(
subc: Arc<SubcConsumer>,
opts: BusClientOptions,
) -> Result<Self>
pub async fn connect( subc: Arc<SubcConsumer>, opts: BusClientOptions, ) -> Result<Self>
Requests a hub credential over the module’s existing daemon route.
Error::HubUnavailable can be retried when the module next needs the
hub. Error::HubNotGranted is terminal. Neither refusal is retried here.
Sourcepub fn client(&self) -> Result<Client>
pub fn client(&self) -> Result<Client>
Returns the current raw NATS client for core publishes. A held snapshot does not follow credential replacements; get a new one after a change.
Sourcepub fn jetstream(&self) -> Result<Context>
pub fn jetstream(&self) -> Result<Context>
Returns a JetStream context on the current connection, in the hub
domain. Like Self::client, it must be reopened after replacement.
Sourcepub fn connection_changes(&self) -> Receiver<u64>
pub fn connection_changes(&self) -> Receiver<u64>
Notifies after a replacement connection is ready. The receiver closes
when maintenance stops, including after a hub refusal. Get a fresh
snapshot with Self::client to check for a typed refusal on closure;
after Error::HubUnavailable, call Self::connect when ready to retry.