pub struct PoolParams {
pub max_connections: u32,
pub min_connections: u32,
pub acquire_timeout: Duration,
pub idle_timeout: Duration,
pub max_lifetime: Duration,
pub query_timeout: Option<Duration>,
pub test_before_acquire: bool,
pub session_init: Vec<String>,
}Expand description
池参数的解析结果(带默认值)。由 SqlxConfig::pool 产出。
Fields§
§max_connections: u32§min_connections: u32§acquire_timeout: Duration§idle_timeout: Duration§max_lifetime: Duration§query_timeout: Option<Duration>§test_before_acquire: bool§session_init: Vec<String>每条新连接建立后执行的会话初始化语句。
Implementations§
Source§impl PoolParams
impl PoolParams
Sourcepub fn for_url(url: &str) -> Self
pub fn for_url(url: &str) -> Self
按 URL 的方言给出「未配置时」的默认参数 —— 含方言默认的 session_init。
与 PoolParams::default 的区别:Default 是结构体默认值(无会话初始化),
本方法才是「用户没配任何东西时应当得到什么」。
connect() 与 from_config() 都必须走这一条,否则两个构造器行为会静默不一致。
Trait Implementations§
Source§impl Clone for PoolParams
impl Clone for PoolParams
Source§impl Debug for PoolParams
impl Debug for PoolParams
Source§impl Default for PoolParams
impl Default for PoolParams
Source§fn default() -> Self
fn default() -> Self
结构体默认值:池大小/超时按文档默认,session_init 为空
(不带任何会话设置)。要「按方言的默认」请用 PoolParams::for_url。
Auto Trait Implementations§
impl Freeze for PoolParams
impl RefUnwindSafe for PoolParams
impl Send for PoolParams
impl Sync for PoolParams
impl Unpin for PoolParams
impl UnsafeUnpin for PoolParams
impl UnwindSafe for PoolParams
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> 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> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request