pub struct Datacenter { /* private fields */ }Expand description
One datacenter.
Mirrors struct datacenter. The
preselected_rack_for_replication field is computed by
crate::cluster::pool::ServerPool::preselect_remote_racks
and reproduces the reference engine’s strategy of choosing one
rack per remote DC for cross-DC writes.
Implementations§
Source§impl Datacenter
impl Datacenter
Sourcepub fn new(name: String) -> Self
pub fn new(name: String) -> Self
Build an empty datacenter.
§Examples
use dynomite::cluster::datacenter::Datacenter;
let dc = Datacenter::new("dc1".into());
assert_eq!(dc.name(), "dc1");Sourcepub fn upsert_rack(&mut self, name: String) -> &mut Rack
pub fn upsert_rack(&mut self, name: String) -> &mut Rack
Insert a rack if absent; return a mutable handle to the
rack regardless. Mirrors server_get_rack.
Sourcepub fn sort_racks(&mut self)
pub fn sort_racks(&mut self)
Sort racks by name (ascending). Used by
crate::cluster::pool::ServerPool::preselect_remote_racks
and mirrors the array_sort(&dc->racks, rack_name_cmp) call
in preselect_remote_rack_for_replication.
Sourcepub fn preselected_rack_idx(&self) -> Option<usize>
pub fn preselected_rack_idx(&self) -> Option<usize>
Preselected rack index for replicating writes from another DC into this DC.
Sourcepub fn preselected_rack(&self) -> Option<&Rack>
pub fn preselected_rack(&self) -> Option<&Rack>
Borrow the preselected rack, if any.
Sourcepub fn set_preselected_rack_idx(&mut self, idx: Option<usize>)
pub fn set_preselected_rack_idx(&mut self, idx: Option<usize>)
Set the preselected rack index (used by the pool’s
preselect_remote_racks
pass).
Trait Implementations§
Source§impl Clone for Datacenter
impl Clone for Datacenter
Source§fn clone(&self) -> Datacenter
fn clone(&self) -> Datacenter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more