Skip to main content

SubRequestClient

Struct SubRequestClient 

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

Hardened sub-request executor wrapping a shared connector.

Provides a safe, bounded execution API that enforces:

  • An overall deadline covering admission, connect, and I/O.
  • Bounded response body reads: each call supplies a per-call limit, clamped to the client-wide ceiling set at construction via with_max_response_bytes. The server derives this ceiling from body_limits.max_response_bytes.
  • Hop-by-hop header sanitization on both request and response.
  • Proper Host framing.

Callers own routing, retries, circuit breaking, SSRF policy, depth propagation, and status interpretation.

Responses are fully buffered. Streaming is not supported by this API.

use praxis_core::subrequest::{SubRequestClient, SubRequestConnector};

let connector = SubRequestConnector::new(128, None);
let client = SubRequestClient::new(connector);

Implementations§

Source§

impl SubRequestClient

Source

pub fn new(connector: SubRequestConnector) -> Self

Create a client wrapping the given shared connector.

Defaults the client-wide response ceiling to ABSOLUTE_MAX_BODY_BYTES (64 MiB). Use with_max_response_bytes for a tighter cap.

Source

pub fn with_max_response_bytes( connector: SubRequestConnector, max_response_bytes: usize, ) -> Self

Create a client with an explicit response ceiling.

Every execute() call clamps its per-call limit to min(per_call, ceiling), preventing callers from exceeding the global cap.

Source

pub fn connector(&self) -> &SubRequestConnector

Access the underlying connector for direct pool operations.

Source

pub fn evict_idle_circuits(&self, idle_threshold: Duration) -> usize

Evict idle circuit breaker entries that have been healthy for at least idle_threshold. Returns the number of entries removed, or 0 if no circuit breaker is configured.

Source

pub async fn execute( &self, peer: &HttpPeer, request: &SubRequest, max_response_bytes: usize, timeout: Duration, framework_headers: Option<&FrameworkHeaders>, ) -> Result<SubResponse, SubRequestError>

Execute a buffered sub-request.

Acquires an admission permit (inside the deadline), connects to peer, sends request, reads the full response (bounded by max_response_bytes), and returns a SubResponse.

Transport-level headers (hop-by-hop, Connection-nominated) and reserved internal headers (x-praxis-*, x-ext-*) are stripped from both request and response.

framework_headers are injected after all sanitisation passes. The FrameworkHeaders type validates at insertion time that no transport-level or reserved internal header (x-praxis-*, x-ext-*) can be added, so callers cannot reintroduce sanitised headers.

§Errors

Returns SubRequestError on admission timeout, connection failure, I/O error, response body exceeding the size limit, or deadline expiry.

Trait Implementations§

Source§

impl Clone for SubRequestClient

Source§

fn clone(&self) -> SubRequestClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SubRequestClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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