Struct redis_tang::Builder
source · [−]pub struct Builder { /* private fields */ }
Implementations
sourceimpl Builder
impl Builder
pub fn new() -> Builder
pub fn max_size(self, max_size: usize) -> Builder
pub fn min_idle(self, min_idle: usize) -> Builder
sourcepub fn always_check(self, always_check: bool) -> Builder
pub fn always_check(self, always_check: bool) -> Builder
If true, the health of a connection will be verified when checkout.
This check uses Builder
’s connection_timeout
setting to cancel the check and return a timeout error.
Defaults to true.
sourcepub fn use_gc(self, use_gc: bool) -> Builder
pub fn use_gc(self, use_gc: bool) -> Builder
If true, the pending connections that last for too long will be removed.( 6 times the connection_timeout
duration)
This is a placeholder feature. it works fine but in most cases it’s not necessary or useful.
Defaults to false.
sourcepub fn max_lifetime(self, max_lifetime: Option<Duration>) -> Builder
pub fn max_lifetime(self, max_lifetime: Option<Duration>) -> Builder
Sets the maximum lifetime of connections in the pool.
If set, connections will be closed at the next reaping after surviving past this duration.
If a connection reaches its maximum lifetime while checked out it will be closed when it is returned to the pool.
Defaults to 30 minutes.
sourcepub fn idle_timeout(self, idle_timeout: Option<Duration>) -> Builder
pub fn idle_timeout(self, idle_timeout: Option<Duration>) -> Builder
Sets the idle timeout used by the pool.
If set, idle connections in excess of min_idle
will be closed at the
next reaping after remaining idle past this duration.
Defaults to 10 minutes.
sourcepub fn reaper_rate(self, reaper_rate: Duration) -> Builder
pub fn reaper_rate(self, reaper_rate: Duration) -> Builder
Sets the connection reaper rate.
The connection that are idle and live beyond the time gate will be dropped.
Default 15 seconds.(no guarantee as we don’t force lock the pool)
sourcepub fn connection_timeout(self, connection_timeout: Duration) -> Builder
pub fn connection_timeout(self, connection_timeout: Duration) -> Builder
Sets the connection timeout used by the pool.
Attempt to establish new connection to database will be canceled and return a timeout error if this Duration passed.
It’s recommended to set this duration the same or a bit longer than your database connection timeout setting.
Default 10 seconds.
sourcepub fn wait_timeout(self, wait_timeout: Duration) -> Builder
pub fn wait_timeout(self, wait_timeout: Duration) -> Builder
Sets the wait timeout used by the queue.
Similar to connection_timeout
. A timeout error will return if we wait too long for a connection from pool.
Default 20 seconds
sourcepub async fn build<M>(
self,
manager: M
) -> Result<Pool<M>, <M as Manager>::Error> where
M: Manager,
pub async fn build<M>(
self,
manager: M
) -> Result<Pool<M>, <M as Manager>::Error> where
M: Manager,
Consumes the Builder
, returning a new, initialized Pool
.
sourcepub fn build_uninitialized<M>(self, manager: M) -> Pool<M> where
M: Manager,
pub fn build_uninitialized<M>(self, manager: M) -> Pool<M> where
M: Manager,
Consumes the Builder
, returning a new uninitialized Pool
.
(Pool
have no connection and scheduled tasks like connection reaper and garbage collect)
sourcepub fn get_reaper_rate(&self) -> Duration
pub fn get_reaper_rate(&self) -> Duration
expose reaper_rate
to public.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more