pub struct SynClient { /* private fields */ }Expand description
Unified RPC client with connection pooling
This is the central client that manages all outgoing RPC connections. Generated service clients use this pool rather than creating their own connections.
The underlying HTTP client (reqwest) automatically pools connections, so SynClient can be cloned cheaply and shared across the application.
Implementations§
Source§impl SynClient
impl SynClient
Sourcepub fn with_protobuf(gateway_url: impl Into<String>) -> Self
pub fn with_protobuf(gateway_url: impl Into<String>) -> Self
Create a client with protobuf encoding (more efficient)
Sourcepub fn with_mtls(
gateway_url: impl Into<String>,
cert_path: impl AsRef<Path>,
key_path: impl AsRef<Path>,
ca_cert_path: impl AsRef<Path>,
) -> Result<Self>
pub fn with_mtls( gateway_url: impl Into<String>, cert_path: impl AsRef<Path>, key_path: impl AsRef<Path>, ca_cert_path: impl AsRef<Path>, ) -> Result<Self>
Create a client with mTLS authentication (production)
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set the request timeout
Sourcepub async fn call(
&self,
interface: impl Into<InterfaceId>,
method: impl Into<MethodId>,
payload: Bytes,
) -> Result<Bytes>
pub async fn call( &self, interface: impl Into<InterfaceId>, method: impl Into<MethodId>, payload: Bytes, ) -> Result<Bytes>
Call a service method with raw bytes
§Arguments
interface- The interface name or IDmethod- The method name or IDpayload- The request payload (serialized)
Sourcepub async fn call_json<TReq, TResp>(
&self,
interface: impl Into<InterfaceId>,
method: impl Into<MethodId>,
request: &TReq,
) -> Result<TResp>where
TReq: Serialize,
TResp: DeserializeOwned,
pub async fn call_json<TReq, TResp>(
&self,
interface: impl Into<InterfaceId>,
method: impl Into<MethodId>,
request: &TReq,
) -> Result<TResp>where
TReq: Serialize,
TResp: DeserializeOwned,
Call with typed request and response (JSON serialization)
This is a convenience method for JSON-serializable types.
Sourcepub async fn call_proto<TReq, TResp>(
&self,
interface: impl Into<InterfaceId>,
method: impl Into<MethodId>,
request: &TReq,
) -> Result<TResp>
pub async fn call_proto<TReq, TResp>( &self, interface: impl Into<InterfaceId>, method: impl Into<MethodId>, request: &TReq, ) -> Result<TResp>
Call with typed request and response (Protobuf serialization)
This is the efficient method for protobuf types. Generated service clients use this method.
Sourcepub fn gateway_url(&self) -> &str
pub fn gateway_url(&self) -> &str
Get the gateway URL