Skip to content

Commit a68275f

Browse files
authored
Merge pull request #1385 from wprzytula/statements-unset-consistency
statements: expose API to unset (serial) consistency
2 parents 454e64a + 587012e commit a68275f

File tree

4 files changed

+53
-11
lines changed

4 files changed

+53
-11
lines changed

scylla/src/cluster/control_connection.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ use crate::statement::Statement;
1818
pub(super) struct ControlConnection {
1919
conn: Arc<Connection>,
2020
/// The custom server-side timeout set for requests executed on the control connection.
21-
overriden_serverside_timeout: Option<Duration>,
21+
overridden_serverside_timeout: Option<Duration>,
2222
}
2323

2424
impl ControlConnection {
2525
pub(super) fn new(conn: Arc<Connection>) -> Self {
2626
Self {
2727
conn,
28-
overriden_serverside_timeout: None,
28+
overridden_serverside_timeout: None,
2929
}
3030
}
3131

3232
/// Sets the custom server-side timeout set for requests executed on the control connection.
33-
pub(super) fn override_serverside_timeout(self, overriden_timeout: Option<Duration>) -> Self {
33+
pub(super) fn override_serverside_timeout(self, overridden_timeout: Option<Duration>) -> Self {
3434
Self {
35-
overriden_serverside_timeout: overriden_timeout,
35+
overridden_serverside_timeout: overridden_timeout,
3636
..self
3737
}
3838
}
@@ -49,7 +49,7 @@ impl ControlConnection {
4949
/// Appends the custom server-side timeout to the statement string, if such custom timeout
5050
/// is provided and we are connected to ScyllaDB (since custom timeouts is ScyllaDB-only feature).
5151
fn maybe_append_timeout_override(&self, statement: &mut Statement) {
52-
if let Some(timeout) = self.overriden_serverside_timeout {
52+
if let Some(timeout) = self.overridden_serverside_timeout {
5353
if self.is_to_scylladb() {
5454
// SAFETY: io::fmt::Write impl for String is infallible.
5555
write!(

scylla/src/statement/batch.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ impl Batch {
6767
self.config.consistency = Some(c);
6868
}
6969

70+
/// Unsets the consistency overridden on this batch.
71+
/// This means that consistency will be derived from the execution profile
72+
/// (per-batch or, if absent, the default one).
73+
pub fn unset_consistency(&mut self) {
74+
self.config.consistency = None;
75+
}
76+
7077
/// Gets the consistency to be used when executing this batch if it is filled.
7178
/// If this is empty, the default_consistency of the session will be used.
7279
pub fn get_consistency(&self) -> Option<Consistency> {
@@ -79,6 +86,13 @@ impl Batch {
7986
self.config.serial_consistency = Some(sc);
8087
}
8188

89+
/// Unsets the serial consistency overridden on this batch.
90+
/// This means that serial consistency will be derived from the execution profile
91+
/// (per-batch or, if absent, the default one).
92+
pub fn unset_serial_consistency(&mut self) {
93+
self.config.serial_consistency = None;
94+
}
95+
8296
/// Gets the serial consistency to be used when executing this batch.
8397
/// (Ignored unless the batch is an LWT)
8498
pub fn get_serial_consistency(&self) -> Option<SerialConsistency> {
@@ -131,7 +145,7 @@ impl Batch {
131145

132146
/// Get the retry policy set for the batch.
133147
///
134-
/// This method returns the retry policy that is **overriden** on this statement.
148+
/// This method returns the retry policy that is **overridden** on this statement.
135149
/// In other words, it returns the retry policy set using [`Batch::set_retry_policy`].
136150
/// This does not take the retry policy from the set execution profile into account.
137151
#[inline]
@@ -150,7 +164,7 @@ impl Batch {
150164

151165
/// Get the load balancing policy set for the batch.
152166
///
153-
/// This method returns the load balancing policy that is **overriden** on this statement.
167+
/// This method returns the load balancing policy that is **overridden** on this statement.
154168
/// In other words, it returns the load balancing policy set using [`Batch::set_load_balancing_policy`].
155169
/// This does not take the load balancing policy from the set execution profile into account.
156170
#[inline]

scylla/src/statement/prepared.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,13 @@ impl PreparedStatement {
298298
self.config.consistency = Some(c);
299299
}
300300

301+
/// Unsets the consistency overridden on this statement.
302+
/// This means that consistency will be derived from the execution profile
303+
/// (per-statement or, if absent, the default one).
304+
pub fn unset_consistency(&mut self) {
305+
self.config.consistency = None;
306+
}
307+
301308
/// Gets the consistency to be used when executing this prepared statement if it is filled.
302309
/// If this is empty, the default_consistency of the session will be used.
303310
pub fn get_consistency(&self) -> Option<Consistency> {
@@ -310,6 +317,13 @@ impl PreparedStatement {
310317
self.config.serial_consistency = Some(sc);
311318
}
312319

320+
/// Unsets the serial consistency overridden on this statement.
321+
/// This means that serial consistency will be derived from the execution profile
322+
/// (per-statement or, if absent, the default one).
323+
pub fn unset_serial_consistency(&mut self) {
324+
self.config.serial_consistency = None;
325+
}
326+
313327
/// Gets the serial consistency to be used when executing this statement.
314328
/// (Ignored unless the statement is an LWT)
315329
pub fn get_serial_consistency(&self) -> Option<SerialConsistency> {
@@ -432,7 +446,7 @@ impl PreparedStatement {
432446

433447
/// Get the retry policy set for the statement.
434448
///
435-
/// This method returns the retry policy that is **overriden** on this statement.
449+
/// This method returns the retry policy that is **overridden** on this statement.
436450
/// In other words, it returns the retry policy set using [`PreparedStatement::set_retry_policy`].
437451
/// This does not take the retry policy from the set execution profile into account.
438452
#[inline]
@@ -451,7 +465,7 @@ impl PreparedStatement {
451465

452466
/// Get the load balancing policy set for the statement.
453467
///
454-
/// This method returns the load balancing policy that is **overriden** on this statement.
468+
/// This method returns the load balancing policy that is **overridden** on this statement.
455469
/// In other words, it returns the load balancing policy set using [`PreparedStatement::set_load_balancing_policy`].
456470
/// This does not take the load balancing policy from the set execution profile into account.
457471
#[inline]

scylla/src/statement/unprepared.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ impl Statement {
6060
self.config.consistency = Some(c);
6161
}
6262

63+
/// Unsets the consistency overridden on this statement.
64+
/// This means that consistency will be derived from the execution profile
65+
/// (per-statement or, if absent, the default one).
66+
pub fn unset_consistency(&mut self) {
67+
self.config.consistency = None;
68+
}
69+
6370
/// Gets the consistency to be used when executing this statement if it is filled.
6471
/// If this is empty, the default_consistency of the session will be used.
6572
pub fn get_consistency(&self) -> Option<Consistency> {
@@ -72,6 +79,13 @@ impl Statement {
7279
self.config.serial_consistency = Some(sc);
7380
}
7481

82+
/// Unsets the serial consistency overridden on this statement.
83+
/// This means that serial consistency will be derived from the execution profile
84+
/// (per-statement or, if absent, the default one).
85+
pub fn unset_serial_consistency(&mut self) {
86+
self.config.serial_consistency = None;
87+
}
88+
7589
/// Gets the serial consistency to be used when executing this statement.
7690
/// (Ignored unless the statement is an LWT)
7791
pub fn get_serial_consistency(&self) -> Option<SerialConsistency> {
@@ -138,7 +152,7 @@ impl Statement {
138152

139153
/// Get the retry policy set for the statement.
140154
///
141-
/// This method returns the retry policy that is **overriden** on this statement.
155+
/// This method returns the retry policy that is **overridden** on this statement.
142156
/// In other words, it returns the retry policy set using [`Statement::set_retry_policy`].
143157
/// This does not take the retry policy from the set execution profile into account.
144158
#[inline]
@@ -157,7 +171,7 @@ impl Statement {
157171

158172
/// Get the load balancing policy set for the statement.
159173
///
160-
/// This method returns the load balancing policy that is **overriden** on this statement.
174+
/// This method returns the load balancing policy that is **overridden** on this statement.
161175
/// In other words, it returns the load balancing policy set using [`Statement::set_load_balancing_policy`].
162176
/// This does not take the load balancing policy from the set execution profile into account.
163177
#[inline]

0 commit comments

Comments
 (0)