pub struct PoolWarmer { /* private fields */ }Expand description
连接池预热器
启动时并发建立 warmup_count 个连接,消除首次请求冷启动。
预热失败时降级到懒加载,不阻塞启动。
Implementations§
Source§impl PoolWarmer
impl PoolWarmer
Sourcepub fn new<F, Fut>(warmup_count: u32, connect_fn: F) -> Self
pub fn new<F, Fut>(warmup_count: u32, connect_fn: F) -> Self
创建 PoolWarmer
warmup_count:预热连接数connect_fn:连接建立闭包(每次调用建立一个连接)
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
设置单连接超时
Sourcepub fn warmup_count(&self) -> u32
pub fn warmup_count(&self) -> u32
预热连接数
Sourcepub async fn warm(&self) -> Result<(), WarmupError>
pub async fn warm(&self) -> Result<(), WarmupError>
执行预热(并发建立 N 个连接)
成功返回 Ok(()),部分失败返回 WarmupError::PartialFailure。
全部失败返回 WarmupError::ConnectionFailed。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PoolWarmer
impl !UnwindSafe for PoolWarmer
impl Freeze for PoolWarmer
impl Send for PoolWarmer
impl Sync for PoolWarmer
impl Unpin for PoolWarmer
impl UnsafeUnpin for PoolWarmer
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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