pub struct Databases { /* private fields */ }Expand description
A primary connection plus an optional read replica.
Implementations§
Source§impl Databases
impl Databases
Sourcepub fn new(writing: DatabaseConnection) -> Self
pub fn new(writing: DatabaseConnection) -> Self
A single-database setup (all queries hit writing).
Sourcepub fn with_reading(self, reading: DatabaseConnection) -> Self
pub fn with_reading(self, reading: DatabaseConnection) -> Self
Add a read replica; reads then route to it.
Sourcepub fn has_replica(&self) -> bool
pub fn has_replica(&self) -> bool
Whether a read replica is configured.
Sourcepub fn connection(&self, role: Role) -> &DatabaseConnection
pub fn connection(&self, role: Role) -> &DatabaseConnection
The connection for role — reads fall back to the writer without a replica.
Sourcepub fn writing(&self) -> &DatabaseConnection
pub fn writing(&self) -> &DatabaseConnection
The writing connection.
Sourcepub fn reading(&self) -> &DatabaseConnection
pub fn reading(&self) -> &DatabaseConnection
The reading connection (falls back to the writer).
Auto Trait Implementations§
impl !RefUnwindSafe for Databases
impl !UnwindSafe for Databases
impl Freeze for Databases
impl Send for Databases
impl Sync for Databases
impl Unpin for Databases
impl UnsafeUnpin for Databases
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