pub struct HttpClient { /* private fields */ }Expand description
Named HTTP service client with deadlines, W3C propagation, response limits, and circuit breaking that treats 5xx responses as dependency failures.
Implementations§
Source§impl HttpClient
impl HttpClient
pub fn new(config: HttpClientConfig) -> Result<Self, HttpClientError>
Sourcepub fn with_metrics(self, metrics: HttpClientMetrics) -> Self
pub fn with_metrics(self, metrics: HttpClientMetrics) -> Self
Records transport outcomes for this client in a shared metrics registry.
pub fn service(&self) -> &str
pub fn breaker_state(&self) -> BreakerState
pub fn breaker_snapshot(&self) -> CircuitBreakerSnapshot
pub fn request(&self, method: Method, url: impl IntoUrl) -> RequestBuilder
Sourcepub async fn execute(
&self,
request: Request,
) -> Result<Response, HttpClientError>
pub async fn execute( &self, request: Request, ) -> Result<Response, HttpClientError>
Executes a pre-built request through the service circuit breaker.
Sourcepub async fn execute_traced(
&self,
request: Request,
parent: &TraceContext,
) -> Result<Response, HttpClientError>
pub async fn execute_traced( &self, request: Request, parent: &TraceContext, ) -> Result<Response, HttpClientError>
Adds a child traceparent header and executes the request.
pub async fn get_json<T>(&self, url: impl IntoUrl) -> Result<T, HttpClientError>where
T: DeserializeOwned,
pub async fn post_json<B, T>( &self, url: impl IntoUrl, body: &B, ) -> Result<T, HttpClientError>
pub async fn decode_json<T>(
&self,
response: Response,
) -> Result<T, HttpClientError>where
T: DeserializeOwned,
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for HttpClient
impl !UnwindSafe for HttpClient
impl Freeze for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl UnsafeUnpin for HttpClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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>
Wrap the input message
T in a tonic::RequestSource§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>
Wrap the input message
T in a tonic::Request