pub struct ConnectionPoolService<T, P, S, BIn = Body, K = UriKey>{ /* private fields */ }client only.Expand description
A service which gets a connection from a possible connection pool and passes it to an inner service to execute that request.
This service will accept http::Request objects, but expects the inner service
to accept ExecuteRequest objects, which bundle the connection with the request.
The simplest interior service is crate::service::RequestExecutor, which will execute the request
on the connection and return the response.
Implementations§
source§impl<T, P, S, BIn, K> ConnectionPoolService<T, P, S, BIn, K>
impl<T, P, S, BIn, K> ConnectionPoolService<T, P, S, BIn, K>
sourcepub fn new(transport: T, protocol: P, service: S, pool: Config) -> Self
pub fn new(transport: T, protocol: P, service: S, pool: Config) -> Self
Create a new client with the given transport, protocol, and pool configuration.
sourcepub fn without_pool(self) -> Self
pub fn without_pool(self) -> Self
Disable connection pooling for this client.
source§impl ConnectionPoolService<TlsTransport<TcpTransport>, HttpConnectionBuilder<Body>, RequestExecutor<HttpConnection<Body>, Body>, Body>
impl ConnectionPoolService<TlsTransport<TcpTransport>, HttpConnectionBuilder<Body>, RequestExecutor<HttpConnection<Body>, Body>, Body>
sourcepub fn new_tcp_http() -> Self
pub fn new_tcp_http() -> Self
Create a new client with the default configuration for making requests over TCP connections using the HTTP protocol.
When the tls feature is enabled, this will also add support for tls when
using the https scheme, with a default TLS configuration that will rely
on the system’s certificate store.
source§impl<P, C, T, S, K, BIn, BOut> ConnectionPoolService<T, P, S, BIn, K>where
C: Connection<BIn, ResBody = BOut> + PoolableConnection,
P: Protocol<T::IO, BIn, Connection = C, Error = ConnectionError> + Clone + Send + Sync + 'static,
T: Transport + 'static,
T::IO: PoolableStream + Unpin,
S: Service<ExecuteRequest<C, BIn>, Response = Response<BOut>> + Clone + Send + 'static,
S::Error: Into<Error>,
BIn: Body + Unpin + Send + 'static,
<BIn as Body>::Data: Send,
<BIn as Body>::Error: Into<Box<dyn Error + Send + Sync>>,
BOut: Body + Unpin + 'static,
<<T as Transport>::IO as HasConnectionInfo>::Addr: Send,
K: Key,
impl<P, C, T, S, K, BIn, BOut> ConnectionPoolService<T, P, S, BIn, K>where
C: Connection<BIn, ResBody = BOut> + PoolableConnection,
P: Protocol<T::IO, BIn, Connection = C, Error = ConnectionError> + Clone + Send + Sync + 'static,
T: Transport + 'static,
T::IO: PoolableStream + Unpin,
S: Service<ExecuteRequest<C, BIn>, Response = Response<BOut>> + Clone + Send + 'static,
S::Error: Into<Error>,
BIn: Body + Unpin + Send + 'static,
<BIn as Body>::Data: Send,
<BIn as Body>::Error: Into<Box<dyn Error + Send + Sync>>,
BOut: Body + Unpin + 'static,
<<T as Transport>::IO as HasConnectionInfo>::Addr: Send,
K: Key,
Trait Implementations§
source§impl<P, T, S, BIn, K> Clone for ConnectionPoolService<T, P, S, BIn, K>where
P: Protocol<T::IO, BIn> + Clone,
P::Connection: PoolableConnection,
T: Transport + Clone,
S: Clone,
K: Key,
impl<P, T, S, BIn, K> Clone for ConnectionPoolService<T, P, S, BIn, K>where
P: Protocol<T::IO, BIn> + Clone,
P::Connection: PoolableConnection,
T: Transport + Clone,
S: Clone,
K: Key,
source§impl<T, P, S: Debug, BIn: Debug, K> Debug for ConnectionPoolService<T, P, S, BIn, K>where
T: Transport + Debug,
P: Protocol<T::IO, BIn> + Debug,
P::Connection: PoolableConnection + Debug,
K: Key + Debug,
impl<T, P, S: Debug, BIn: Debug, K> Debug for ConnectionPoolService<T, P, S, BIn, K>where
T: Transport + Debug,
P: Protocol<T::IO, BIn> + Debug,
P::Connection: PoolableConnection + Debug,
K: Key + Debug,
source§impl<P, C, T, S, BIn, BOut, K> Service<Request<BIn>> for ConnectionPoolService<T, P, S, BIn, K>where
C: Connection<BIn, ResBody = BOut> + PoolableConnection,
P: Protocol<T::IO, BIn, Connection = C, Error = ConnectionError> + Clone + Send + Sync + 'static,
T: Transport + Send + 'static,
T::IO: PoolableStream + Unpin,
<<T as Transport>::IO as HasConnectionInfo>::Addr: Send,
S: Service<ExecuteRequest<C, BIn>, Response = Response<BOut>> + Clone + Send + 'static,
S::Error: Into<Error>,
BOut: Body + Unpin + 'static,
BIn: Body + Unpin + Send + 'static,
<BIn as Body>::Data: Send,
<BIn as Body>::Error: Into<Box<dyn Error + Send + Sync>>,
K: Key,
impl<P, C, T, S, BIn, BOut, K> Service<Request<BIn>> for ConnectionPoolService<T, P, S, BIn, K>where
C: Connection<BIn, ResBody = BOut> + PoolableConnection,
P: Protocol<T::IO, BIn, Connection = C, Error = ConnectionError> + Clone + Send + Sync + 'static,
T: Transport + Send + 'static,
T::IO: PoolableStream + Unpin,
<<T as Transport>::IO as HasConnectionInfo>::Addr: Send,
S: Service<ExecuteRequest<C, BIn>, Response = Response<BOut>> + Clone + Send + 'static,
S::Error: Into<Error>,
BOut: Body + Unpin + 'static,
BIn: Body + Unpin + Send + 'static,
<BIn as Body>::Data: Send,
<BIn as Body>::Error: Into<Box<dyn Error + Send + Sync>>,
K: Key,
Auto Trait Implementations§
impl<T, P, S, BIn, K> Freeze for ConnectionPoolService<T, P, S, BIn, K>
impl<T, P, S, BIn = Body, K = UriKey> !RefUnwindSafe for ConnectionPoolService<T, P, S, BIn, K>
impl<T, P, S, BIn, K> Send for ConnectionPoolService<T, P, S, BIn, K>
impl<T, P, S, BIn, K> Sync for ConnectionPoolService<T, P, S, BIn, K>
impl<T, P, S, BIn, K> Unpin for ConnectionPoolService<T, P, S, BIn, K>
impl<T, P, S, BIn = Body, K = UriKey> !UnwindSafe for ConnectionPoolService<T, P, S, BIn, K>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T, BIn, BOut> HttpService<BIn> for T
impl<T, BIn, BOut> HttpService<BIn> for T
source§type Error = <T as Service<Request<BIn>>>::Error
type Error = <T as Service<Request<BIn>>>::Error
Service. Read morefn poll_ready( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), <T as HttpService<BIn>>::Error>>
fn call(&mut self, req: Request<BIn>) -> <T as HttpService<BIn>>::Future
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
source§impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
source§fn into_make_service(self) -> IntoMakeService<S>
fn into_make_service(self) -> IntoMakeService<S>
MakeService, that is a Service whose
response is another service. Read moresource§fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<S, C>
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<S, C>
tokio only.MakeService, that will store C’s
associated ConnectInfo in a request extension such that ConnectInfo
can extract it. Read moresource§fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
HandleError, that will handle errors
by converting them into responses. Read moresource§impl<T, Request> ServiceExt<Request> for T
impl<T, Request> ServiceExt<Request> for T
source§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
source§fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
ServiceExt::ready method insteadsource§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
source§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Service, calling with the providing request once it is ready.source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
poll_ready method. Read moresource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
poll_ready method. Read moresource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
poll_ready method. Read moresource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Result<Self::Response, Self::Error>)
to a different value, regardless of whether the future succeeds or
fails. Read moresource§fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
source§fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
source§fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
source§impl<T, Request> ServiceExt<Request> for T
impl<T, Request> ServiceExt<Request> for T
source§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
source§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
source§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Service, calling it with the provided request once it is ready.source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
poll_ready method. Read moresource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
poll_ready method. Read moresource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
poll_ready method. Read moresource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Result<Self::Response, Self::Error>)
to a different value, regardless of whether the future succeeds or
fails. Read more