Struct wasmbus_rpc::RpcClient [−][src]
pub struct RpcClient { /* fields omitted */ }
Expand description
Send wasmbus rpc messages
The primary use of RpcClient is providers sending to actors, however providers don’t need to construct this - one is created by HostBridge, which providers create during initialization.
This class is also used by wash and test tools for sending rpc messages to actors and providers. Note that sending to a provider requires an existing link definition, and, the message needs to be signed by a valid cluster key.
This RpcClient does not subscribe to rpc topics. To subscribe, use the nats client api directly.
Implementations
Constructs a new RpcClient for the async nats connection. parameters: async nats client, lattice rpc prefix (usually “default”), and secret key for signing messages
Constructs a new RpcClient for a nats::asynk connection. parameters: async nats client, lattice rpc prefix (usually “default”), and secret key for signing messages
convenience method for returning async client If the client is not the correct type, returns None
convenience method for returning nats::asynk Connection If the client is not the correct type, returns None
pub async fn send_json<Target, Arg, Resp>(
&self,
origin: WasmCloudEntity,
target: Target,
method: &str,
data: JsonValue
) -> Result<JsonValue, RpcError> where
Arg: DeserializeOwned + Serialize,
Resp: DeserializeOwned + Serialize,
Target: Into<WasmCloudEntity>,
pub async fn send_json<Target, Arg, Resp>(
&self,
origin: WasmCloudEntity,
target: Target,
method: &str,
data: JsonValue
) -> Result<JsonValue, RpcError> where
Arg: DeserializeOwned + Serialize,
Resp: DeserializeOwned + Serialize,
Target: Into<WasmCloudEntity>,
Send an rpc message using json-encoded data
pub async fn send<Target>(
&self,
origin: WasmCloudEntity,
target: Target,
message: Message<'_>
) -> Result<Vec<u8>, RpcError> where
Target: Into<WasmCloudEntity>,
pub async fn send<Target>(
&self,
origin: WasmCloudEntity,
target: Target,
message: Message<'_>
) -> Result<Vec<u8>, RpcError> where
Target: Into<WasmCloudEntity>,
Send a wasmbus rpc message by wrapping with an Invocation before sending over nats. ‘target’ may be &str or String for sending to an actor, or a WasmCloudEntity (for actor or provider) If nats client is sync, this can block the current thread. If a response is not received within the default timeout, the Error RpcError::Timeout is returned.
pub async fn send_timeout<Target>(
&self,
origin: WasmCloudEntity,
target: Target,
message: Message<'_>,
timeout: Duration
) -> Result<Vec<u8>, RpcError> where
Target: Into<WasmCloudEntity>,
pub async fn send_timeout<Target>(
&self,
origin: WasmCloudEntity,
target: Target,
message: Message<'_>,
timeout: Duration
) -> Result<Vec<u8>, RpcError> where
Target: Into<WasmCloudEntity>,
Send a wasmbus rpc message, with a timeout. The rpc message is wrapped with an Invocation before sending over nats. ‘target’ may be &str or String for sending to an actor, or a WasmCloudEntity (for actor or provider) If nats client is sync, this can block the current thread until either the response is received, or the timeout expires. If the timeout expires before the response is received, this returns Error RpcError::Timeout.
Send a nats message and wait for the response. This can be used for general nats messages, not just wasmbus actor/provider messages. If the nats client is sync, this can block the current thread
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for RpcClient
impl !UnwindSafe for RpcClient
Blanket Implementations
Mutably borrows from an owned value. Read more