TokenHttpClient

Trait TokenHttpClient 

Source
pub trait TokenHttpClient
where Self: 'static + Send + Sync,
{ type TransportError: 'static + Send + Sync + StdError; type Handle: for<'c> AsyncHttpClient<'c, Error = HttpClientError<Self::TransportError>, Future: 'c + Send> + 'static + Send + Sync; // Required method fn with_metadata(&self, slot: ResponseMetadataSlot) -> Self::Handle; }
Expand description

Abstraction over HTTP transports capable of executing OAuth token exchanges while publishing response metadata to the broker’s instrumentation pipeline.

The trait acts as the broker’s only dependency on an HTTP stack. Callers provide an implementation (typically behind Arc<T> where T: TokenHttpClient) and the broker requests short-lived AsyncHttpClient handles that each carry a clone of a ResponseMetadataSlot. Implementations must be Send + Sync + 'static so they can be shared across broker instances without additional wrappers, and the handles they return must own whatever state is required so their request futures remain Send for the lifetime of the in-flight operation. This lets facade callers box the async blocks without worrying about borrowed transports.

Required Associated Types§

Source

type TransportError: 'static + Send + Sync + StdError

Concrete error emitted by the underlying transport.

Source

type Handle: for<'c> AsyncHttpClient<'c, Error = HttpClientError<Self::TransportError>, Future: 'c + Send> + 'static + Send + Sync

AsyncHttpClient handle tied to a ResponseMetadataSlot.

Each handle must satisfy Send + Sync so broker futures can hop executors without cloning transports unnecessarily. The request future returned by AsyncHttpClient::call must also be Send so the facade’s boxed futures inherit the same guarantee.

Required Methods§

Source

fn with_metadata(&self, slot: ResponseMetadataSlot) -> Self::Handle

Builds an AsyncHttpClient handle that records outcomes in slot.

§Metadata Contract
  • Call ResponseMetadataSlot::take before submitting the HTTP request so stale information never leaks across retries.
  • Once an HTTP response (successful or erroneous) provides status headers, save them with ResponseMetadataSlot::store.
  • Never retain the slot clone beyond the lifetime of the returned handle; the handle itself enforces borrowing rules for the transport.

Implementors§

Source§

impl TokenHttpClient for ReqwestHttpClient

Available on crate feature reqwest only.