pub enum Consistency {
Any,
One,
Two,
Three,
Quorum,
All,
LocalQuorum,
EachQuorum,
Serial,
LocalSerial,
LocalOne,
}
Expand description
Consistency
is an enum which represents Cassandra’s consistency levels.
To find more details about each consistency level please refer to the following documentation:
https://docs.datastax.com/en/cql-oss/3.x/cql/cql_reference/cqlshConsistency.html
Variants
Any
Closest replica, as determined by the snitch. If all replica nodes are down, write succeeds after a hinted handoff. Provides low latency, guarantees writes never fail. Note: this consistency level can only be used for writes. It provides the lowest consistency and the highest availability.
One
A write must be written to the commit log and memtable of at least one replica node. Satisfies the needs of most users because consistency requirements are not stringent.
Two
A write must be written to the commit log and memtable of at least two replica nodes. Similar to ONE.
Three
A write must be written to the commit log and memtable of at least three replica nodes. Similar to TWO.
Quorum
A write must be written to the commit log and memtable on a quorum of replica nodes. Provides strong consistency if you can tolerate some level of failure.
All
A write must be written to the commit log and memtable on all replica nodes in the cluster for that partition key. Provides the highest consistency and the lowest availability of any other level.
LocalQuorum
Strong consistency. A write must be written to the commit log and memtable on a quorum of replica nodes in the same data center as thecoordinator node. Avoids latency of inter-data center communication. Used in multiple data center clusters with a rack-aware replica placement strategy, such as NetworkTopologyStrategy, and a properly configured snitch. Use to maintain consistency locally (within the single data center). Can be used with SimpleStrategy.
EachQuorum
Strong consistency. A write must be written to the commit log and memtable on a quorum of replica nodes in all data center. Used in multiple data center clusters to strictly maintain consistency at the same level in each data center. For example, choose this level if you want a read to fail when a data center is down and the QUORUM cannot be reached on that data center.
Serial
Achieves linearizable consistency for lightweight transactions by preventing unconditional updates. You cannot configure this level as a normal consistency level, configured at the driver level using the consistency level field. You configure this level using the serial consistency field as part of the native protocol operation. See failure scenarios.
LocalSerial
Same as SERIAL but confined to the data center. A write must be written conditionally to the commit log and memtable on a quorum of replica nodes in the same data center. Same as SERIAL. Used for disaster recovery. See failure scenarios.
LocalOne
A write must be sent to, and successfully acknowledged by, at least one replica node in the local data center. In a multiple data center clusters, a consistency level of ONE is often desirable, but cross-DC traffic is not. LOCAL_ONE accomplishes this. For security and quality reasons, you can use this consistency level in an offline datacenter to prevent automatic connection to online nodes in other data centers if an offline node goes down.
Implementations
sourceimpl Consistency
impl Consistency
sourcepub fn is_dc_local(self) -> bool
pub fn is_dc_local(self) -> bool
Does this consistency require local dc.
Trait Implementations
sourceimpl Clone for Consistency
impl Clone for Consistency
sourcefn clone(&self) -> Consistency
fn clone(&self) -> Consistency
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for Consistency
impl Debug for Consistency
sourceimpl Default for Consistency
impl Default for Consistency
sourcefn default() -> Consistency
fn default() -> Consistency
sourceimpl Display for Consistency
impl Display for Consistency
sourceimpl From<Consistency> for CIntShort
impl From<Consistency> for CIntShort
sourcefn from(value: Consistency) -> Self
fn from(value: Consistency) -> Self
sourceimpl FromBytes for Consistency
impl FromBytes for Consistency
sourcefn from_bytes(bytes: &[u8]) -> Result<Consistency>
fn from_bytes(bytes: &[u8]) -> Result<Consistency>
sourceimpl FromCursor for Consistency
impl FromCursor for Consistency
sourcefn from_cursor(
cursor: &mut Cursor<&[u8]>,
version: Version
) -> Result<Consistency>
fn from_cursor(
cursor: &mut Cursor<&[u8]>,
version: Version
) -> Result<Consistency>
sourceimpl FromStr for Consistency
impl FromStr for Consistency
sourceimpl Hash for Consistency
impl Hash for Consistency
sourceimpl Ord for Consistency
impl Ord for Consistency
sourcefn cmp(&self, other: &Consistency) -> Ordering
fn cmp(&self, other: &Consistency) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl PartialEq<Consistency> for Consistency
impl PartialEq<Consistency> for Consistency
sourcefn eq(&self, other: &Consistency) -> bool
fn eq(&self, other: &Consistency) -> bool
sourceimpl PartialOrd<Consistency> for Consistency
impl PartialOrd<Consistency> for Consistency
sourcefn partial_cmp(&self, other: &Consistency) -> Option<Ordering>
fn partial_cmp(&self, other: &Consistency) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more