pub struct SentinelConnectionManager { /* private fields */ }Expand description
bb8 的 bb8::ManageConnection 实现。
内部持有 Arc<Mutex<SentinelClient>>,因为 SentinelClient::async_get_connection
需要 &mut self。建立新连接的时间通常是毫秒级,所以串行化并不会成为热路径瓶颈。
Implementations§
Source§impl SentinelConnectionManager
impl SentinelConnectionManager
Sourcepub fn new(config: SentinelPoolConfig) -> Result<Self>
pub fn new(config: SentinelPoolConfig) -> Result<Self>
基于 SentinelPoolConfig 构造一个新的 manager。
Sourcepub fn bump_epoch(&self) -> u64
pub fn bump_epoch(&self) -> u64
让所有当前在池里的连接立刻被识别为“已坏“。
后台 watcher 收到 +switch-master 事件时会调用本方法。也可以
在业务代码里手动调用,例如收到自定义运维信号时。
Sourcepub fn current_epoch(&self) -> u64
pub fn current_epoch(&self) -> u64
当前 epoch。
Trait Implementations§
Source§impl Clone for SentinelConnectionManager
impl Clone for SentinelConnectionManager
Source§fn clone(&self) -> SentinelConnectionManager
fn clone(&self) -> SentinelConnectionManager
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ManageConnection for SentinelConnectionManager
impl ManageConnection for SentinelConnectionManager
Source§type Connection = PooledConnection
type Connection = PooledConnection
The connection type this manager deals with.
Source§type Error = SentinelPoolError
type Error = SentinelPoolError
The error type returned by
Connections.Source§fn connect(&self) -> impl Future<Output = Result<Self::Connection>> + Send
fn connect(&self) -> impl Future<Output = Result<Self::Connection>> + Send
Attempts to create a new connection.
Source§fn is_valid(
&self,
conn: &mut Self::Connection,
) -> impl Future<Output = Result<()>> + Send
fn is_valid( &self, conn: &mut Self::Connection, ) -> impl Future<Output = Result<()>> + Send
Determines if the connection is still connected to the database.
Source§fn has_broken(&self, conn: &mut Self::Connection) -> bool
fn has_broken(&self, conn: &mut Self::Connection) -> bool
Synchronously determine if the connection is no longer usable, if possible.
Auto Trait Implementations§
impl Freeze for SentinelConnectionManager
impl !RefUnwindSafe for SentinelConnectionManager
impl Send for SentinelConnectionManager
impl Sync for SentinelConnectionManager
impl Unpin for SentinelConnectionManager
impl UnsafeUnpin for SentinelConnectionManager
impl !UnwindSafe for SentinelConnectionManager
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