pub struct ConnectionRouter { /* private fields */ }Expand description
Connection router for read/write splitting.
Implementations§
Source§impl ConnectionRouter
impl ConnectionRouter
Sourcepub fn new(config: ReplicaSetConfig) -> Self
pub fn new(config: ReplicaSetConfig) -> Self
Create a new router.
Sourcepub fn route(
&self,
query_type: QueryType,
preference: Option<&ReadPreference>,
) -> QueryResult<&ReplicaConfig>
pub fn route( &self, query_type: QueryType, preference: Option<&ReadPreference>, ) -> QueryResult<&ReplicaConfig>
Get replica for a query based on query type and read preference.
Sourcepub fn get_primary(&self) -> QueryResult<&ReplicaConfig>
pub fn get_primary(&self) -> QueryResult<&ReplicaConfig>
Get the primary replica.
Sourcepub fn update_health(
&mut self,
id: &str,
status: HealthStatus,
latency: Option<Duration>,
lag: Option<Duration>,
)
pub fn update_health( &mut self, id: &str, status: HealthStatus, latency: Option<Duration>, lag: Option<Duration>, )
Update health status of a replica.
Sourcepub fn check_lag(&self, replica_id: &str, max_lag: Duration) -> bool
pub fn check_lag(&self, replica_id: &str, max_lag: Duration) -> bool
Check if replication lag is acceptable.
Sourcepub fn initiate_failover(&mut self) -> QueryResult<String>
pub fn initiate_failover(&mut self) -> QueryResult<String>
Initiate failover to a new primary.
Sourcepub fn is_in_failover(&self) -> bool
pub fn is_in_failover(&self) -> bool
Check if router is currently in failover mode.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ConnectionRouter
impl RefUnwindSafe for ConnectionRouter
impl Send for ConnectionRouter
impl Sync for ConnectionRouter
impl Unpin for ConnectionRouter
impl UnwindSafe for ConnectionRouter
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