Skip to content

Commit 2584966

Browse files
committed
batch: add request timeout setter/getter
Batch was missing request timeout setter and getter. As a bonus, docstrings were updated in PreparedStatement and Statement to account for execution profiles.
1 parent 454e64a commit 2584966

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

scylla/src/statement/batch.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::borrow::Cow;
22
use std::sync::Arc;
3+
use std::time::Duration;
34

45
use crate::client::execution_profile::ExecutionProfileHandle;
56
use crate::observability::history::HistoryListener;
@@ -123,6 +124,19 @@ impl Batch {
123124
self.config.timestamp
124125
}
125126

127+
/// Sets the client-side timeout for this batch.
128+
/// If not None, the driver will stop waiting for the request
129+
/// to finish after `timeout` passed.
130+
/// Otherwise, execution profile timeout will be applied.
131+
pub fn set_request_timeout(&mut self, timeout: Option<Duration>) {
132+
self.config.request_timeout = timeout
133+
}
134+
135+
/// Gets client timeout associated with this batch.
136+
pub fn get_request_timeout(&self) -> Option<Duration> {
137+
self.config.request_timeout
138+
}
139+
126140
/// Set the retry policy for this batch, overriding the one from execution profile if not None.
127141
#[inline]
128142
pub fn set_retry_policy(&mut self, retry_policy: Option<Arc<dyn RetryPolicy>>) {

scylla/src/statement/prepared.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl PreparedStatement {
379379
/// Sets the client-side timeout for this statement.
380380
/// If not None, the driver will stop waiting for the request
381381
/// to finish after `timeout` passed.
382-
/// Otherwise, default session client timeout will be applied.
382+
/// Otherwise, execution profile timeout will be applied.
383383
pub fn set_request_timeout(&mut self, timeout: Option<Duration>) {
384384
self.config.request_timeout = timeout
385385
}

scylla/src/statement/unprepared.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl Statement {
120120
/// Sets the client-side timeout for this statement.
121121
/// If not None, the driver will stop waiting for the request
122122
/// to finish after `timeout` passed.
123-
/// Otherwise, default session client timeout will be applied.
123+
/// Otherwise, execution profile timeout will be applied.
124124
pub fn set_request_timeout(&mut self, timeout: Option<Duration>) {
125125
self.config.request_timeout = timeout
126126
}

0 commit comments

Comments
 (0)