pub struct CoalescingClient { /* private fields */ }Expand description
An HTTP client decorator that joins safe, identical requests already in flight.
Only bodyless GET and HEAD requests are coalesced. Cookie-jar identity and
proxy selection are part of the key, so distinct sessions and routes never share
a fetch. Joined callers of a failed request receive an Other error because
HttpClientError is not cloneable; this intentionally loses connect/timeout
variant fidelity.
§Examples
use std::sync::Arc;
use millipede_http::{CoalescingClient, ReqwestClient};
let inner = Arc::new(ReqwestClient::new()?);
let client = CoalescingClient::new(inner);Implementations§
Source§impl CoalescingClient
impl CoalescingClient
Sourcepub fn new(inner: Arc<dyn HttpClient>) -> Self
pub fn new(inner: Arc<dyn HttpClient>) -> Self
Wraps an HTTP client with in-flight request coalescing.
Trait Implementations§
Source§impl Debug for CoalescingClient
impl Debug for CoalescingClient
Source§impl HttpClient for CoalescingClient
impl HttpClient for CoalescingClient
Source§fn send<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends a request and buffers the complete response body.
Source§fn stream<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<StreamingResponse, HttpClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<StreamingResponse, HttpClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends a request and returns a streaming response body.
Auto Trait Implementations§
impl !Freeze for CoalescingClient
impl !RefUnwindSafe for CoalescingClient
impl !UnwindSafe for CoalescingClient
impl Send for CoalescingClient
impl Sync for CoalescingClient
impl Unpin for CoalescingClient
impl UnsafeUnpin for CoalescingClient
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
Mutably borrows from an owned value. Read more