Struct hyperdriver::client::ConnectionPoolService
source · pub struct ConnectionPoolService<T, P, S, BIn = Body>{ /* 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> ConnectionPoolService<T, P, S, BIn>
impl<T, P, S, BIn> ConnectionPoolService<T, P, S, BIn>
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, BIn, BOut> ConnectionPoolService<T, P, S, BIn>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: Unpin,
S: Service<ExecuteRequest<C, BIn>, Response = Response<BOut>> + Clone,
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,
impl<P, C, T, S, BIn, BOut> ConnectionPoolService<T, P, S, BIn>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: Unpin,
S: Service<ExecuteRequest<C, BIn>, Response = Response<BOut>> + Clone,
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,
Trait Implementations§
source§impl<P, T, S, BIn> Clone for ConnectionPoolService<T, P, S, BIn>where
P: Protocol<T::IO, BIn> + Clone,
P::Connection: PoolableConnection,
T: Transport + Clone,
S: Clone,
impl<P, T, S, BIn> Clone for ConnectionPoolService<T, P, S, BIn>where
P: Protocol<T::IO, BIn> + Clone,
P::Connection: PoolableConnection,
T: Transport + Clone,
S: Clone,
source§impl<T, P, S: Debug, BIn: Debug> Debug for ConnectionPoolService<T, P, S, BIn>where
T: Transport + Debug,
P: Protocol<T::IO, BIn> + Debug,
P::Connection: PoolableConnection + Debug,
impl<T, P, S: Debug, BIn: Debug> Debug for ConnectionPoolService<T, P, S, BIn>where
T: Transport + Debug,
P: Protocol<T::IO, BIn> + Debug,
P::Connection: PoolableConnection + Debug,
source§impl<P, C, T, S, BIn, BOut> Service<Request<BIn>> for ConnectionPoolService<T, P, S, BIn>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: Unpin,
<<T as Transport>::IO as HasConnectionInfo>::Addr: Send,
S: Service<ExecuteRequest<C, BIn>, Response = Response<BOut>> + Clone,
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>>,
impl<P, C, T, S, BIn, BOut> Service<Request<BIn>> for ConnectionPoolService<T, P, S, BIn>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: Unpin,
<<T as Transport>::IO as HasConnectionInfo>::Addr: Send,
S: Service<ExecuteRequest<C, BIn>, Response = Response<BOut>> + Clone,
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>>,
§type Future = ResponseFuture<<P as Protocol<<T as Transport>::IO, BIn>>::Connection, TransportStream<<T as Transport>::IO>, S, BIn, BOut>
type Future = ResponseFuture<<P as Protocol<<T as Transport>::IO, BIn>>::Connection, TransportStream<<T as Transport>::IO>, S, BIn, BOut>
Auto Trait Implementations§
impl<T, P, S, BIn> Freeze for ConnectionPoolService<T, P, S, BIn>
impl<T, P, S, BIn = Body> !RefUnwindSafe for ConnectionPoolService<T, P, S, BIn>
impl<T, P, S, BIn> Send for ConnectionPoolService<T, P, S, BIn>
impl<T, P, S, BIn> Sync for ConnectionPoolService<T, P, S, BIn>
impl<T, P, S, BIn> Unpin for ConnectionPoolService<T, P, S, BIn>
impl<T, P, S, BIn = Body> !UnwindSafe for ConnectionPoolService<T, P, S, BIn>
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default 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§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 more