pub struct ConnectorClient { /* private fields */ }Expand description
gRPC client for connector communication
Supports two transport modes:
TransportType::Grpc(default): Native gRPC over HTTP/2TransportType::WebSocket: WebSocket over HTTP/1.1 (for corporate proxy compatibility)
§Example
use strike48_connector::{ConnectorClient, client::{ClientOptions, TransportType}};
// Using native gRPC (default)
let client = ConnectorClient::new("connectors-poc-us.strike48.com:443".to_string(), true);
// Using WebSocket for corporate proxy compatibility
let client = ConnectorClient::with_options(ClientOptions {
host: "connectors-poc-us.strike48.com:443".to_string(),
use_tls: true,
transport: TransportType::WebSocket,
default_timeout_ms: 30000,
});Implementations§
Source§impl ConnectorClient
impl ConnectorClient
Sourcepub fn new(host: String, use_tls: bool) -> Self
pub fn new(host: String, use_tls: bool) -> Self
Create a new ConnectorClient with default transport (gRPC).
For URL-based transport auto-detection, use with_options with url.
Sourcepub fn with_options(opts: ClientOptions) -> Self
pub fn with_options(opts: ClientOptions) -> Self
Create a new ConnectorClient with full configuration.
Transport is auto-detected from URL scheme when using url option:
grpc://orgrpcs://→ gRPC transportws://,wss://,http://,https://→ WebSocket transport
§Examples
// Auto-detect transport from URL (recommended)
let client = ConnectorClient::with_options(ClientOptions {
url: Some("grpcs://connectors.example.com:443".to_string()),
..Default::default()
});
// WebSocket transport (auto-detected from wss://)
let client = ConnectorClient::with_options(ClientOptions {
url: Some("wss://connectors.example.com:443".to_string()),
..Default::default()
});Sourcepub async fn connect_channel(&mut self) -> Result<()>
pub async fn connect_channel(&mut self) -> Result<()>
Connect to Strike48 server using the configured transport.
Uses the configured transport:
TransportType::Grpc: Native gRPC over HTTP/2 (default)TransportType::WebSocket: WebSocket over HTTP/1.1 (for corporate proxy compatibility)
Sourcepub async fn send_register_request(
&self,
tenant_id: &str,
connector_type: &str,
instance_id: &str,
capabilities: &ConnectorCapabilities,
auth_token: &str,
) -> Result<()>
pub async fn send_register_request( &self, tenant_id: &str, connector_type: &str, instance_id: &str, capabilities: &ConnectorCapabilities, auth_token: &str, ) -> Result<()>
Send registration request on the stream Note: Registration happens through the bidirectional stream, not a separate RPC
Sourcepub async fn start_stream_with_registration(
&mut self,
initial_message: ProtoStreamMessage,
) -> Result<(UnboundedSender<ProtoStreamMessage>, UnboundedReceiver<ProtoStreamMessage>)>
pub async fn start_stream_with_registration( &mut self, initial_message: ProtoStreamMessage, ) -> Result<(UnboundedSender<ProtoStreamMessage>, UnboundedReceiver<ProtoStreamMessage>)>
Start bidirectional streaming using the transport abstraction.
This method works identically for both gRPC and WebSocket transports. The transport handles protocol-specific details internally.
A background keepalive task is automatically spawned that sends
HeartbeatRequest messages every 30 seconds. This prevents the
server’s session reaper (90s timeout) from killing the session,
regardless of whether the caller sends their own metrics/heartbeats.
Sourcepub async fn send_message(&self, message: ProtoStreamMessage) -> Result<()>
pub async fn send_message(&self, message: ProtoStreamMessage) -> Result<()>
Send a message on the stream
Sourcepub async fn set_session_token(&self, token: String)
pub async fn set_session_token(&self, token: String)
Set session token
Sourcepub async fn send_response(&self, response: ExecuteResponse) -> Result<()>
pub async fn send_response(&self, response: ExecuteResponse) -> Result<()>
Send execute response
Sourcepub async fn disconnect(&mut self)
pub async fn disconnect(&mut self)
Disconnect from Strike48 server
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if connected (lock-free atomic check)
Sourcepub fn is_registered(&self) -> bool
pub fn is_registered(&self) -> bool
Check if registered (lock-free atomic check)
Sourcepub fn mark_registered(&self)
pub fn mark_registered(&self)
Mark this client as successfully registered with the server.
Sourcepub async fn invoke_capability(
&self,
target_address: &str,
payload: Vec<u8>,
options: InvokeOptions,
) -> Result<Option<InvokeCapabilityResponse>>
pub async fn invoke_capability( &self, target_address: &str, payload: Vec<u8>, options: InvokeOptions, ) -> Result<Option<InvokeCapabilityResponse>>
Invoke a capability on another connector through Strike48 routing
Sourcepub fn get_default_timeout(&self) -> Option<u64>
pub fn get_default_timeout(&self) -> Option<u64>
Get default timeout in milliseconds
Auto Trait Implementations§
impl Freeze for ConnectorClient
impl !RefUnwindSafe for ConnectorClient
impl Send for ConnectorClient
impl Sync for ConnectorClient
impl Unpin for ConnectorClient
impl UnsafeUnpin for ConnectorClient
impl !UnwindSafe for ConnectorClient
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request