From 98b799bae094bbfcb5a17d64827014cbc0366efb Mon Sep 17 00:00:00 2001 From: Patrick MARIE Date: Mon, 22 Feb 2021 13:41:39 +0100 Subject: [PATCH] Refactoring: consistencies. --- src/cassandra.rs | 12 ++++++------ src/main.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cassandra.rs b/src/cassandra.rs index 431be75..b6af77c 100644 --- a/src/cassandra.rs +++ b/src/cassandra.rs @@ -36,7 +36,7 @@ pub fn fetch_metric(session: &Session, metric_name: &str) -> Result) -> Result Result<(), Error> { query.bind(1, config)?; // config query.bind(2, CassUuid::from_str(&uuid.to_hyphenated().to_string())?)?; - query.set_consistency(Consistency::LOCAL_QUORUM)?; + query.set_consistency(session.write_consistency())?; session.metadata_session().execute(&query).wait()?; @@ -209,17 +209,17 @@ pub fn metric_delete(session: &Session, metric_name: &str) -> Result<(), Error> let mut query = stmt!("DELETE FROM biggraphite_metadata.metrics_metadata WHERE name = ?;"); query.bind(0, metric_name)?; - query.set_consistency(Consistency::LOCAL_QUORUM)?; + query.set_consistency(session.write_consistency())?; session.metadata_session().execute(&query).wait()?; let mut query = stmt!("DELETE FROM biggraphite_metadata.metrics_metadata WHERE name = ?;"); query.bind(0, metric_name)?; - query.set_consistency(Consistency::LOCAL_QUORUM)?; + query.set_consistency(session.write_consistency())?; session.metadata_session().execute(&query).wait()?; let mut query = stmt!("DELETE FROM biggraphite_metadata.directories WHERE name = ?;"); query.bind(0, metric_name)?; - query.set_consistency(Consistency::LOCAL_QUORUM)?; + query.set_consistency(session.write_consistency())?; session.metadata_session().execute(&query).wait()?; Ok(()) diff --git a/src/main.rs b/src/main.rs index a5ea6bc..61dcff4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,7 +91,7 @@ fn metric_list(session: &Session, glob: &str) -> Result<(), Error> { let components = glob.split(".").collect::>(); let mut query_directories = prepare_component_query("directories", &components)?; - query_directories.set_consistency(Consistency::QUORUM)?; + query_directories.set_consistency(session.read_consistency())?; let result = session.metadata_session().execute(&query_directories).wait()?; for row in result.iter() { let name = row.get_column_by_name("name".to_string()).unwrap().to_string(); @@ -99,7 +99,7 @@ fn metric_list(session: &Session, glob: &str) -> Result<(), Error> { } let mut query = prepare_component_query("metrics", &components)?; - query.set_consistency(Consistency::QUORUM)?; + query.set_consistency(session.read_consistency())?; let result = session.metadata_session().execute(&query).wait()?; let names = result