pub struct DatabaseConfig {
pub write: String,
pub read: Vec<String>,
pub read_strategy: ReadStrategy,
}Expand description
Connection-URL configuration for a primary + optional read replicas.
use rok_orm_core::replica::{DatabaseConfig, ReadStrategy};
let cfg = DatabaseConfig::new("postgres://primary/db")
.with_replica("postgres://replica1/db")
.with_replica("postgres://replica2/db")
.with_strategy(ReadStrategy::RoundRobin);
assert!(cfg.has_replicas());Fields§
§write: StringWrite (primary) database URL.
read: Vec<String>Read replica URLs. Empty means all queries go to write.
read_strategy: ReadStrategyStrategy for distributing reads across read replicas.
Implementations§
Source§impl DatabaseConfig
impl DatabaseConfig
pub fn new(write: impl Into<String>) -> Self
pub fn with_replica(self, url: impl Into<String>) -> Self
pub fn with_strategy(self, strategy: ReadStrategy) -> Self
pub fn has_replicas(&self) -> bool
Trait Implementations§
Source§impl Clone for DatabaseConfig
impl Clone for DatabaseConfig
Source§fn clone(&self) -> DatabaseConfig
fn clone(&self) -> DatabaseConfig
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 moreAuto Trait Implementations§
impl Freeze for DatabaseConfig
impl RefUnwindSafe for DatabaseConfig
impl Send for DatabaseConfig
impl Sync for DatabaseConfig
impl Unpin for DatabaseConfig
impl UnsafeUnpin for DatabaseConfig
impl UnwindSafe for DatabaseConfig
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