pub struct AgentClientV2Uds { /* private fields */ }Expand description
v2 agent client over Unix Domain Socket.
This client maintains a single connection and multiplexes multiple requests over it using correlation IDs, similar to the gRPC client.
Implementations§
Source§impl AgentClientV2Uds
impl AgentClientV2Uds
Sourcepub async fn new(
agent_id: impl Into<String>,
socket_path: impl Into<String>,
timeout: Duration,
) -> Result<Self, AgentProtocolError>
pub async fn new( agent_id: impl Into<String>, socket_path: impl Into<String>, timeout: Duration, ) -> Result<Self, AgentProtocolError>
Create a new UDS v2 client.
Sourcepub async fn encoding(&self) -> UdsEncoding
pub async fn encoding(&self) -> UdsEncoding
Get the current negotiated encoding.
Sourcepub fn set_metrics_callback(&mut self, callback: MetricsCallback)
pub fn set_metrics_callback(&mut self, callback: MetricsCallback)
Set the metrics callback.
Sourcepub fn set_config_update_callback(&mut self, callback: ConfigUpdateCallback)
pub fn set_config_update_callback(&mut self, callback: ConfigUpdateCallback)
Set the config update callback.
Sourcepub async fn connect(&self) -> Result<(), AgentProtocolError>
pub async fn connect(&self) -> Result<(), AgentProtocolError>
Connect and perform handshake.
Sourcepub async fn capabilities(&self) -> Option<AgentCapabilities>
pub async fn capabilities(&self) -> Option<AgentCapabilities>
Get negotiated capabilities.
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if connected.
Sourcepub async fn send_request_headers(
&self,
correlation_id: &str,
event: &RequestHeadersEvent,
) -> Result<AgentResponse, AgentProtocolError>
pub async fn send_request_headers( &self, correlation_id: &str, event: &RequestHeadersEvent, ) -> Result<AgentResponse, AgentProtocolError>
Send a request headers event.
Sourcepub async fn send_request_body_chunk(
&self,
correlation_id: &str,
event: &RequestBodyChunkEvent,
) -> Result<AgentResponse, AgentProtocolError>
pub async fn send_request_body_chunk( &self, correlation_id: &str, event: &RequestBodyChunkEvent, ) -> Result<AgentResponse, AgentProtocolError>
Send a request body chunk event.
Sourcepub async fn send_response_headers(
&self,
correlation_id: &str,
event: &ResponseHeadersEvent,
) -> Result<AgentResponse, AgentProtocolError>
pub async fn send_response_headers( &self, correlation_id: &str, event: &ResponseHeadersEvent, ) -> Result<AgentResponse, AgentProtocolError>
Send a response headers event.
Sourcepub async fn send_response_body_chunk(
&self,
correlation_id: &str,
event: &ResponseBodyChunkEvent,
) -> Result<AgentResponse, AgentProtocolError>
pub async fn send_response_body_chunk( &self, correlation_id: &str, event: &ResponseBodyChunkEvent, ) -> Result<AgentResponse, AgentProtocolError>
Send a response body chunk event.
Sourcepub async fn send_request_complete(
&self,
correlation_id: &str,
event: &RequestCompleteEvent,
) -> Result<AgentResponse, AgentProtocolError>
pub async fn send_request_complete( &self, correlation_id: &str, event: &RequestCompleteEvent, ) -> Result<AgentResponse, AgentProtocolError>
Send a request complete event.
Sourcepub async fn send_websocket_frame(
&self,
correlation_id: &str,
event: &WebSocketFrameEvent,
) -> Result<AgentResponse, AgentProtocolError>
pub async fn send_websocket_frame( &self, correlation_id: &str, event: &WebSocketFrameEvent, ) -> Result<AgentResponse, AgentProtocolError>
Send a WebSocket frame event.
Sourcepub async fn send_guardrail_inspect(
&self,
correlation_id: &str,
event: &GuardrailInspectEvent,
) -> Result<AgentResponse, AgentProtocolError>
pub async fn send_guardrail_inspect( &self, correlation_id: &str, event: &GuardrailInspectEvent, ) -> Result<AgentResponse, AgentProtocolError>
Send a guardrail inspect event.
Sourcepub async fn send_configure(
&self,
correlation_id: &str,
event: &Value,
) -> Result<AgentResponse, AgentProtocolError>
pub async fn send_configure( &self, correlation_id: &str, event: &Value, ) -> Result<AgentResponse, AgentProtocolError>
Send a configure event.
Sourcepub async fn send_request_body_chunk_binary(
&self,
event: &BinaryRequestBodyChunkEvent,
) -> Result<AgentResponse, AgentProtocolError>
pub async fn send_request_body_chunk_binary( &self, event: &BinaryRequestBodyChunkEvent, ) -> Result<AgentResponse, AgentProtocolError>
Send a binary request body chunk event (zero-copy path).
This method avoids base64 encoding when using MessagePack encoding, sending raw bytes directly over the wire for better throughput.
§Performance
When MessagePack encoding is negotiated:
- Bytes are serialized directly (no base64 encode/decode)
- Reduces CPU usage and latency for large bodies
When JSON encoding is used:
- Falls back to base64 encoding for JSON compatibility
Sourcepub async fn send_response_body_chunk_binary(
&self,
event: &BinaryResponseBodyChunkEvent,
) -> Result<AgentResponse, AgentProtocolError>
pub async fn send_response_body_chunk_binary( &self, event: &BinaryResponseBodyChunkEvent, ) -> Result<AgentResponse, AgentProtocolError>
Send a binary response body chunk event (zero-copy path).
This method avoids base64 encoding when using MessagePack encoding, sending raw bytes directly over the wire for better throughput.
Sourcepub async fn cancel_request(
&self,
correlation_id: &str,
reason: CancelReason,
) -> Result<(), AgentProtocolError>
pub async fn cancel_request( &self, correlation_id: &str, reason: CancelReason, ) -> Result<(), AgentProtocolError>
Send a cancel request for a specific correlation ID.
Sourcepub async fn cancel_all(
&self,
reason: CancelReason,
) -> Result<usize, AgentProtocolError>
pub async fn cancel_all( &self, reason: CancelReason, ) -> Result<usize, AgentProtocolError>
Cancel all in-flight requests.
Sourcepub async fn ping(&self) -> Result<(), AgentProtocolError>
pub async fn ping(&self) -> Result<(), AgentProtocolError>
Send a ping.
Sourcepub async fn close(&self) -> Result<(), AgentProtocolError>
pub async fn close(&self) -> Result<(), AgentProtocolError>
Close the connection.
Sourcepub async fn is_paused(&self) -> bool
pub async fn is_paused(&self) -> bool
Check if the agent has requested flow control pause.
Returns true if the agent sent a FlowAction::Pause signal,
indicating it cannot accept more requests.
Sourcepub async fn can_accept_requests(&self) -> bool
pub async fn can_accept_requests(&self) -> bool
Check if the transport can accept new requests.
Returns false if the agent has requested a flow control pause.
Auto Trait Implementations§
impl !Freeze for AgentClientV2Uds
impl !RefUnwindSafe for AgentClientV2Uds
impl Send for AgentClientV2Uds
impl Sync for AgentClientV2Uds
impl Unpin for AgentClientV2Uds
impl UnsafeUnpin for AgentClientV2Uds
impl !UnwindSafe for AgentClientV2Uds
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