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 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
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.