Skip to content

Commit 8616e72

Browse files
authored
Merge pull request #1391 from wprzytula/batch-set-timeout
batch: add request timeout setter/getter
2 parents a68275f + 2584966 commit 8616e72

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;
@@ -137,6 +138,19 @@ impl Batch {
137138
self.config.timestamp
138139
}
139140

141+
/// Sets the client-side timeout for this batch.
142+
/// If not None, the driver will stop waiting for the request
143+
/// to finish after `timeout` passed.
144+
/// Otherwise, execution profile timeout will be applied.
145+
pub fn set_request_timeout(&mut self, timeout: Option<Duration>) {
146+
self.config.request_timeout = timeout
147+
}
148+
149+
/// Gets client timeout associated with this batch.
150+
pub fn get_request_timeout(&self) -> Option<Duration> {
151+
self.config.request_timeout
152+
}
153+
140154
/// Set the retry policy for this batch, overriding the one from execution profile if not None.
141155
#[inline]
142156
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
@@ -393,7 +393,7 @@ impl PreparedStatement {
393393
/// Sets the client-side timeout for this statement.
394394
/// If not None, the driver will stop waiting for the request
395395
/// to finish after `timeout` passed.
396-
/// Otherwise, default session client timeout will be applied.
396+
/// Otherwise, execution profile timeout will be applied.
397397
pub fn set_request_timeout(&mut self, timeout: Option<Duration>) {
398398
self.config.request_timeout = timeout
399399
}

scylla/src/statement/unprepared.rs

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

0 commit comments

Comments
 (0)