Skip to main content

ModelClient

Struct ModelClient 

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

Client for a ModelService server’s Join bidi stream.

§Concurrency: demux by request_id

Responses are demultiplexed by request_id through a shared pending map, so multiple requests can be in flight on one connection at once. A response pump routes each response to the matching waiter; a response with no pending waiter (a late one from an abandoned request, or an unknown id) is logged and dropped.

The public per-request methods (predict, configure_route, close_route, close) take &mut self and await their own response, so used alone they behave exactly as before (one request at a time, response matched by id). To actually overlap predicts on one connection, use predict_concurrent, which takes &self and may be called from multiple tasks concurrently. The matching server advertises the rlmesh.model.concurrent_predict.v1 capability when it pipelines.

Implementations§

Source§

impl ModelClient

Source

pub async fn connect(address: &str, token: &str) -> Result<Self, GrpcError>

Source

pub async fn connect_with_retry( address: &str, token: &str, options: &ConnectOptions, ) -> Result<Self, GrpcError>

Connect to a ModelService server, retrying until the server accepts the connection (or the deadline/cancellation in options fires).

Only the transport connect is retried; perform the handshake explicitly on the returned client.

Source

pub fn address(&self) -> &str

Source

pub fn take_last_telemetry(&mut self) -> Option<OperationTelemetry>

Source

pub fn server_pipelines_predict(&self) -> bool

Whether the server advertised that it pipelines Join-stream predicts (rlmesh.model.concurrent_predict.v1). Advisory: overlapping predicts via predict_concurrent work either way, but serialize behind the handler when this is false.

Source

pub async fn handshake(&mut self) -> Result<(), GrpcError>

Source

pub async fn configure_route( &mut self, request: ConfigureRouteRequest, ) -> Result<(), GrpcError>

Source

pub async fn predict( &mut self, request: PredictRequest, ) -> Result<PredictResponse, GrpcError>

Source

pub async fn close_route( &mut self, request: CloseRouteRequest, ) -> Result<(), GrpcError>

Source

pub async fn close( &mut self, reason: impl Into<String>, ) -> Result<(), GrpcError>

Source

pub async fn close_with_timeout( &mut self, reason: impl Into<String>, timeout: Duration, ) -> Result<(), GrpcError>

Source

pub async fn shutdown( &mut self, reason: impl Into<String>, ) -> Result<ShutdownResponse, GrpcError>

Source

pub async fn predict_concurrent( &self, request: PredictRequest, ) -> Result<PredictResponse, GrpcError>

Issue a predict that may overlap other in-flight requests on the same connection. Takes &self, so it can be called from multiple tasks concurrently; responses are demuxed by request_id.

Unlike predict, this does not record last_telemetry (that field is single-threaded &mut self state); read per-call telemetry from the returned response if needed. The server only pipelines these when it advertises rlmesh.model.concurrent_predict.v1; against a serial server they still complete correctly, just serialized.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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