pub struct Connector<T, U> { /* private fields */ }
Expand description
Manages http client network connectivity
The Connector
type uses a builder-like combinator pattern for service
construction that finishes by calling the .finish()
method.
use std::time::Duration;
use scrappy_http::client::Connector;
let connector = Connector::new()
.timeout(Duration::from_secs(5))
.finish();
Implementations§
Source§impl Connector<(), ()>
impl Connector<(), ()>
pub fn new() -> Connector<impl Service<Request = TcpConnect<Uri>, Response = TcpConnection<Uri, TcpStream>, Error = ConnectError> + Clone, TcpStream>
Source§impl<T, U> Connector<T, U>
impl<T, U> Connector<T, U>
Sourcepub fn connector<T1, U1>(self, connector: T1) -> Connector<T1, U1>where
U1: AsyncRead + AsyncWrite + Unpin + Debug,
T1: Service<Request = TcpConnect<Uri>, Response = TcpConnection<Uri, U1>, Error = ConnectError> + Clone,
pub fn connector<T1, U1>(self, connector: T1) -> Connector<T1, U1>where
U1: AsyncRead + AsyncWrite + Unpin + Debug,
T1: Service<Request = TcpConnect<Uri>, Response = TcpConnection<Uri, U1>, Error = ConnectError> + Clone,
Use custom connector.
Source§impl<T, U> Connector<T, U>where
U: AsyncRead + AsyncWrite + Unpin + Debug + 'static,
T: Service<Request = Connect<Uri>, Response = Connection<Uri, U>, Error = ConnectError> + Clone + 'static,
impl<T, U> Connector<T, U>where
U: AsyncRead + AsyncWrite + Unpin + Debug + 'static,
T: Service<Request = Connect<Uri>, Response = Connection<Uri, U>, Error = ConnectError> + Clone + 'static,
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Connection timeout, i.e. max time to connect to remote host including dns name resolution. Set to 1 second by default.
Sourcepub fn limit(self, limit: usize) -> Self
pub fn limit(self, limit: usize) -> Self
Set total number of simultaneous connections per type of scheme.
If limit is 0, the connector has no limit. The default limit size is 100.
Sourcepub fn conn_keep_alive(self, dur: Duration) -> Self
pub fn conn_keep_alive(self, dur: Duration) -> Self
Set keep-alive period for opened connection.
Keep-alive period is the period between connection usage. If the delay between repeated usages of the same connection exceeds this period, the connection is closed. Default keep-alive period is 15 seconds.
Sourcepub fn conn_lifetime(self, dur: Duration) -> Self
pub fn conn_lifetime(self, dur: Duration) -> Self
Set max lifetime period for connection.
Connection lifetime is max lifetime of any opened connection until it is closed regardless of keep-alive period. Default lifetime period is 75 seconds.
Sourcepub fn disconnect_timeout(self, dur: Duration) -> Self
pub fn disconnect_timeout(self, dur: Duration) -> Self
Set server connection disconnect timeout in milliseconds.
Defines a timeout for disconnect connection. If a disconnect procedure does not complete within this time, the socket get dropped. This timeout affects only secure connections.
To disable timeout set value to 0.
By default disconnect timeout is set to 3000 milliseconds.
Sourcepub fn finish(
self,
) -> impl Service<Request = Connect, Response = impl Connection, Error = ConnectError> + Clone
pub fn finish( self, ) -> impl Service<Request = Connect, Response = impl Connection, Error = ConnectError> + Clone
Finish configuration process and create connector service.
The Connector builder always concludes by calling finish()
last in
its combinator chain.
Auto Trait Implementations§
impl<T, U> Freeze for Connector<T, U>where
T: Freeze,
impl<T, U> RefUnwindSafe for Connector<T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for Connector<T, U>
impl<T, U> Sync for Connector<T, U>
impl<T, U> Unpin for Connector<T, U>
impl<T, U> UnwindSafe for Connector<T, U>where
T: UnwindSafe,
U: UnwindSafe,
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> 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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more