pub struct ReplicaPool { /* private fields */ }Expand description
Multi-Database Read Replica Load Balancer. Transparently load-balances read queries across secondary replicas while sending write queries to the primary database.
Implementations§
Source§impl ReplicaPool
impl ReplicaPool
Sourcepub fn new(primary: RullstPool, replicas: Vec<RullstPool>) -> Self
pub fn new(primary: RullstPool, replicas: Vec<RullstPool>) -> Self
Creates a new ReplicaPool with a primary pool and a list of read replica pools.
Sourcepub fn primary_only(primary: RullstPool) -> Self
pub fn primary_only(primary: RullstPool) -> Self
Creates a ReplicaPool with only a primary pool (no read replicas).
Sourcepub fn read(&self) -> &RullstPool
pub fn read(&self) -> &RullstPool
Returns a pool reference for read queries using Round-Robin balancing across replicas. Falls back to the primary pool if no replicas are available.
Sourcepub fn write(&self) -> &RullstPool
pub fn write(&self) -> &RullstPool
Returns a pool reference to the primary database for write/mutation operations.
Sourcepub fn replica_count(&self) -> usize
pub fn replica_count(&self) -> usize
Returns the number of active read replicas configured.
Auto Trait Implementations§
impl !Freeze for ReplicaPool
impl !RefUnwindSafe for ReplicaPool
impl !UnwindSafe for ReplicaPool
impl Send for ReplicaPool
impl Sync for ReplicaPool
impl Unpin for ReplicaPool
impl UnsafeUnpin for ReplicaPool
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
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