pub struct Datacenter { /* private fields */ }Expand description
One datacenter.
A datacenter and its racks. The
preselected_rack_for_replication field is computed by
crate::cluster::pool::ServerPool::preselect_remote_racks
and selects 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
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 moreSource§impl Debug for Datacenter
impl Debug for Datacenter
Source§impl From<&Datacenter> for DatacenterSnapshot
impl From<&Datacenter> for DatacenterSnapshot
Source§fn from(dc: &Datacenter) -> Self
fn from(dc: &Datacenter) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Datacenter
impl RefUnwindSafe for Datacenter
impl Send for Datacenter
impl Sync for Datacenter
impl Unpin for Datacenter
impl UnsafeUnpin for Datacenter
impl UnwindSafe for Datacenter
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