Skip to main content

ConnectorClient

Struct ConnectorClient 

Source
pub struct ConnectorClient { /* private fields */ }
Expand description

gRPC client for connector communication

Supports two transport modes:

  • TransportType::Grpc (default): Native gRPC over HTTP/2
  • TransportType::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

Source

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.

Source

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:// or grpcs:// → gRPC transport
  • ws://, 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()
});
Source

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)
Source

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

Source

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.

Source

pub async fn send_message(&self, message: ProtoStreamMessage) -> Result<()>

Send a message on the stream

Source

pub async fn set_session_token(&self, token: String)

Set session token

Source

pub async fn send_response(&self, response: ExecuteResponse) -> Result<()>

Send execute response

Source

pub async fn disconnect(&mut self)

Disconnect from Strike48 server

Source

pub fn is_connected(&self) -> bool

Check if connected (lock-free atomic check)

Source

pub fn is_registered(&self) -> bool

Check if registered (lock-free atomic check)

Source

pub fn mark_registered(&self)

Mark this client as successfully registered with the server.

Source

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

Source

pub fn get_default_timeout(&self) -> Option<u64>

Get default timeout in milliseconds

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more