pub struct Builder<Tls = TlsUnset> { /* private fields */ }Expand description
Builds a partition-aware connection pool.
Implementations§
Source§impl<Tls> Builder<Tls>
impl<Tls> Builder<Tls>
Sourcepub fn idle_timeout(self, timeout: impl Into<Option<Duration>>) -> Self
pub fn idle_timeout(self, timeout: impl Into<Option<Duration>>) -> Self
Sets how long a reusable idle connection remains in the pool.
Passing None disables idle expiration. When unset, the pool uses a
90-second timeout.
Sourcepub fn set_idle_timeout(
&mut self,
timeout: Option<Option<Duration>>,
) -> &mut Self
pub fn set_idle_timeout( &mut self, timeout: Option<Option<Duration>>, ) -> &mut Self
Mutably sets the idle timeout.
The outer None restores the default; Some(None) disables expiry.
Sourcepub fn time_source(self, source: impl TimeSource + 'static) -> Self
pub fn time_source(self, source: impl TimeSource + 'static) -> Self
Sets the clock used by pool maintenance and connection timing.
Sourcepub fn set_time_source(&mut self, source: Option<SharedTimeSource>) -> &mut Self
pub fn set_time_source(&mut self, source: Option<SharedTimeSource>) -> &mut Self
Mutably sets the clock used by pool maintenance and connection timing.
Sourcepub fn sleep_impl(self, sleep: impl AsyncSleep + 'static) -> Self
pub fn sleep_impl(self, sleep: impl AsyncSleep + 'static) -> Self
Sets the sleep implementation used by pool maintenance.
Sourcepub fn set_sleep_impl(&mut self, sleep: Option<SharedAsyncSleep>) -> &mut Self
pub fn set_sleep_impl(&mut self, sleep: Option<SharedAsyncSleep>) -> &mut Self
Mutably sets the sleep implementation used by pool maintenance.
Sourcepub fn tcp_nodelay(self, enabled: bool) -> Self
pub fn tcp_nodelay(self, enabled: bool) -> Self
Configures TCP_NODELAY for newly created sockets.
Sourcepub fn set_tcp_nodelay(&mut self, enabled: bool) -> &mut Self
pub fn set_tcp_nodelay(&mut self, enabled: bool) -> &mut Self
Mutably configures TCP_NODELAY.
Sourcepub fn tcp_keepalive(self, time: impl Into<Option<Duration>>) -> Self
pub fn tcp_keepalive(self, time: impl Into<Option<Duration>>) -> Self
Configures TCP keepalive for newly created sockets.
Sourcepub fn set_tcp_keepalive(&mut self, time: Option<Option<Duration>>) -> &mut Self
pub fn set_tcp_keepalive(&mut self, time: Option<Option<Duration>>) -> &mut Self
Mutably configures TCP keepalive.
Sourcepub fn max_connections_per_host(self, limit: usize) -> Self
pub fn max_connections_per_host(self, limit: usize) -> Self
Bounds connection capacity for one origin across every pool partition.
An origin is a scheme, host, and port, so https://example.com and
http://example.com are bounded separately, as is each non-default
port. Establishing, idle, and active connections occupy capacity.
Logical close normally returns capacity while accepted work drains.
An HTTP/1 upgrade retains capacity until the caller releases upgraded
I/O. This is not an idle-connection limit.
Sourcepub fn set_max_connections_per_host(
&mut self,
limit: Option<usize>,
) -> &mut Self
pub fn set_max_connections_per_host( &mut self, limit: Option<usize>, ) -> &mut Self
Mutably sets the connection-capacity bound described by
Builder::max_connections_per_host.
Sourcepub fn connection_reuse_scope(self, scope: ConnectionReuseScope) -> Self
pub fn connection_reuse_scope(self, scope: ConnectionReuseScope) -> Self
Selects which partitions may reuse each other’s connections.
Sourcepub fn set_connection_reuse_scope(
&mut self,
scope: ConnectionReuseScope,
) -> &mut Self
pub fn set_connection_reuse_scope( &mut self, scope: ConnectionReuseScope, ) -> &mut Self
Mutably selects the connection reuse scope.
Sourcepub fn partitions(self, partitions: impl IntoIterator<Item = Partition>) -> Self
pub fn partitions(self, partitions: impl IntoIterator<Item = Partition>) -> Self
Declares the complete explicit partition set.
Sourcepub fn set_partitions(
&mut self,
partitions: Option<Vec<Partition>>,
) -> &mut Self
pub fn set_partitions( &mut self, partitions: Option<Vec<Partition>>, ) -> &mut Self
Mutably declares or clears the explicit partition set.
Sourcepub fn proxy_config(self, config: ProxyConfig) -> Self
pub fn proxy_config(self, config: ProxyConfig) -> Self
Configures proxy selection for every connection established by this pool.
The configuration applies across every partition. Proxying is disabled unless this method is called.
Sourcepub fn set_proxy_config(&mut self, config: Option<ProxyConfig>) -> &mut Self
pub fn set_proxy_config(&mut self, config: Option<ProxyConfig>) -> &mut Self
Mutably configures pool-wide proxy selection.
Passing None disables proxying.
Sourcepub fn dns_resolver(self, resolver: impl ResolveDns + 'static) -> Self
pub fn dns_resolver(self, resolver: impl ResolveDns + 'static) -> Self
Configures the DNS resolver used by connections established by this pool.
The resolver applies across every partition. When unset, the client uses its default resolver, which currently delegates to the operating system.
Sourcepub fn set_dns_resolver(
&mut self,
resolver: Option<SharedDnsResolver>,
) -> &mut Self
pub fn set_dns_resolver( &mut self, resolver: Option<SharedDnsResolver>, ) -> &mut Self
Mutably configures the pool-wide DNS resolver.
Passing None restores the client default.
Sourcepub fn event_listener(self, listener: impl ConnectionEventListener) -> Self
pub fn event_listener(self, listener: impl ConnectionEventListener) -> Self
Observes connection establishment and installed-lifetime transitions.
The listener applies to every partition. Each callback runs synchronously on the task that completed the transition and after pool locks are released. A listener must not block on work that requires progress from that same task.
Observation is disabled unless a listener is configured.
Sourcepub fn set_event_listener(
&mut self,
listener: Option<SharedConnectionEventListener>,
) -> &mut Self
pub fn set_event_listener( &mut self, listener: Option<SharedConnectionEventListener>, ) -> &mut Self
Mutably configures pool-wide connection lifecycle observation.
Passing None disables observation. The callback contract is the same
as Builder::event_listener.
Source§impl Builder<TlsUnset>
impl Builder<TlsUnset>
Sourcepub fn tls_provider(self, provider: Provider) -> Builder<TlsProviderSelected>
pub fn tls_provider(self, provider: Provider) -> Builder<TlsProviderSelected>
Selects the TLS provider used by HTTPS pool connections.
Source§impl Builder<TlsProviderSelected>
impl Builder<TlsProviderSelected>
Sourcepub fn tls_context(self, context: TlsContext) -> Self
pub fn tls_context(self, context: TlsContext) -> Self
Sets provider-specific TLS configuration for HTTPS connections.
Sourcepub fn set_tls_context(&mut self, context: TlsContext) -> &mut Self
pub fn set_tls_context(&mut self, context: TlsContext) -> &mut Self
Mutably sets provider-specific TLS configuration.
Sourcepub fn build_https(self) -> Result<ConnectionPool, BuildError>
pub fn build_https(self) -> Result<ConnectionPool, BuildError>
Builds a pool whose connector performs TLS and ALPN negotiation.
Trait Implementations§
Auto Trait Implementations§
impl<Tls = TlsUnset> !Freeze for Builder<Tls>
impl<Tls = TlsUnset> !RefUnwindSafe for Builder<Tls>
impl<Tls = TlsUnset> !UnwindSafe for Builder<Tls>
impl<Tls> Send for Builder<Tls>where
Tls: Send,
impl<Tls> Sync for Builder<Tls>where
Tls: Sync,
impl<Tls> Unpin for Builder<Tls>where
Tls: Unpin,
impl<Tls> UnsafeUnpin for Builder<Tls>where
Tls: UnsafeUnpin,
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§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