pub struct BasiliskClient {
pub gateway: GatewayApiClient,
pub bus: BusClient,
pub service_id: String,
pub instance_id: String,
}Expand description
High-level client that combines gateway registration APIs and the service-bus client.
Fields§
§gateway: GatewayApiClientGateway API client handle.
bus: BusClientService bus client handle.
service_id: StringCurrent service id.
instance_id: StringRegistered instance id.
Implementations§
Source§impl BasiliskClient
impl BasiliskClient
Sourcepub async fn connect(config: BasiliskClientConfig) -> Result<Self>
pub async fn connect(config: BasiliskClientConfig) -> Result<Self>
Registers the instance with the gateway and opens an authenticated bus connection.
Sourcepub async fn deregister(&self) -> Result<()>
pub async fn deregister(&self) -> Result<()>
Deregisters this instance from the gateway registry.
Sourcepub async fn subscribe(&self, topics: Vec<String>) -> ClientResult<()>
pub async fn subscribe(&self, topics: Vec<String>) -> ClientResult<()>
Subscribes this client to the provided topics.
Sourcepub async fn unsubscribe(&self, topics: Vec<String>) -> ClientResult<()>
pub async fn unsubscribe(&self, topics: Vec<String>) -> ClientResult<()>
Unsubscribes this client from the provided topics.
Sourcepub async fn publish(
&self,
topic: impl Into<String>,
message_type: impl Into<String>,
payload: HashMap<String, Value>,
) -> ClientResult<i32>
pub async fn publish( &self, topic: impl Into<String>, message_type: impl Into<String>, payload: HashMap<String, Value>, ) -> ClientResult<i32>
Publishes an event and returns the number of subscribers that received it.
Sourcepub async fn publish_event(
&self,
event: ServiceBusEventEnvelope,
) -> ClientResult<i32>
pub async fn publish_event( &self, event: ServiceBusEventEnvelope, ) -> ClientResult<i32>
Publishes a fully constructed event envelope.
Sourcepub async fn forward(
&self,
request: ForwardRequest,
) -> ClientResult<ServiceBusForwardResponse>
pub async fn forward( &self, request: ForwardRequest, ) -> ClientResult<ServiceBusForwardResponse>
Sends a forward request and waits for a forward response.
Sourcepub async fn on_event<F, Fut>(
&self,
topic: impl Into<String>,
handler: F,
) -> ClientResult<()>
pub async fn on_event<F, Fut>( &self, topic: impl Into<String>, handler: F, ) -> ClientResult<()>
Registers an async event handler for a topic.
Sourcepub async fn on_request<F, Fut>(
&self,
topic: impl Into<String>,
responder: F,
) -> ClientResult<()>where
F: Fn(ServiceBusRequest, RequestResponder) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ClientResult<()>> + Send + 'static,
pub async fn on_request<F, Fut>(
&self,
topic: impl Into<String>,
responder: F,
) -> ClientResult<()>where
F: Fn(ServiceBusRequest, RequestResponder) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ClientResult<()>> + Send + 'static,
Registers an async request responder keyed by message type.
Trait Implementations§
Source§impl Clone for BasiliskClient
impl Clone for BasiliskClient
Source§fn clone(&self) -> BasiliskClient
fn clone(&self) -> BasiliskClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for BasiliskClient
impl !UnwindSafe for BasiliskClient
impl Freeze for BasiliskClient
impl Send for BasiliskClient
impl Sync for BasiliskClient
impl Unpin for BasiliskClient
impl UnsafeUnpin for BasiliskClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more