File tree Expand file tree Collapse file tree 3 files changed +32
-6
lines changed Expand file tree Collapse file tree 3 files changed +32
-6
lines changed Original file line number Diff line number Diff line change 1- use std:: sync:: Arc ;
1+ use std:: { sync:: Arc , time :: Duration } ;
22
33use crate :: transport:: retry_policy:: RetryPolicy ;
44use crate :: transport:: speculative_execution:: SpeculativeExecutionPolicy ;
@@ -21,6 +21,7 @@ pub struct StatementConfig {
2121
2222 pub tracing : bool ,
2323 pub timestamp : Option < i64 > ,
24+ pub request_timeout : Option < Duration > ,
2425}
2526
2627impl Default for StatementConfig {
@@ -33,23 +34,20 @@ impl Default for StatementConfig {
3334 speculative_execution_policy : None ,
3435 tracing : false ,
3536 timestamp : None ,
37+ request_timeout : None ,
3638 }
3739 }
3840}
3941
4042impl Clone for StatementConfig {
4143 fn clone ( & self ) -> Self {
4244 Self {
43- consistency : self . consistency ,
44- serial_consistency : self . serial_consistency ,
45- is_idempotent : self . is_idempotent ,
4645 retry_policy : self
4746 . retry_policy
4847 . as_ref ( )
4948 . map ( |policy| policy. clone_boxed ( ) ) ,
5049 speculative_execution_policy : self . speculative_execution_policy . clone ( ) ,
51- tracing : self . tracing ,
52- timestamp : self . timestamp ,
50+ ..* self
5351 }
5452 }
5553}
Original file line number Diff line number Diff line change 11use bytes:: { BufMut , Bytes , BytesMut } ;
22use smallvec:: { smallvec, SmallVec } ;
33use std:: convert:: TryInto ;
4+ use std:: time:: Duration ;
45use thiserror:: Error ;
56use uuid:: Uuid ;
67
@@ -247,6 +248,19 @@ impl PreparedStatement {
247248 self . config . timestamp
248249 }
249250
251+ /// Sets the client-side timeout for this statement.
252+ /// If not None, the driver will stop waiting for the request
253+ /// to finish after `timeout` passed.
254+ /// Otherwise, default session client timeout will be applied.
255+ pub fn set_request_timeout ( & mut self , timeout : Option < Duration > ) {
256+ self . config . request_timeout = timeout
257+ }
258+
259+ /// Gets client timeout associated with this query
260+ pub fn get_request_timeout ( & self ) -> Option < Duration > {
261+ self . config . request_timeout
262+ }
263+
250264 /// Sets the name of the partitioner used for this statement.
251265 pub ( crate ) fn set_partitioner_name ( & mut self , partitioner_name : Option < & str > ) {
252266 self . partitioner_name = match partitioner_name {
Original file line number Diff line number Diff line change 11use super :: StatementConfig ;
22use crate :: frame:: types:: { Consistency , SerialConsistency } ;
33use crate :: transport:: retry_policy:: RetryPolicy ;
4+ use std:: time:: Duration ;
45
56/// CQL query statement.
67///
@@ -117,6 +118,19 @@ impl Query {
117118 pub fn get_timestamp ( & self ) -> Option < i64 > {
118119 self . config . timestamp
119120 }
121+
122+ /// Sets the client-side timeout for this statement.
123+ /// If not None, the driver will stop waiting for the request
124+ /// to finish after `timeout` passed.
125+ /// Otherwise, default session client timeout will be applied.
126+ pub fn set_request_timeout ( & mut self , timeout : Option < Duration > ) {
127+ self . config . request_timeout = timeout
128+ }
129+
130+ /// Gets client timeout associated with this query
131+ pub fn get_request_timeout ( & self ) -> Option < Duration > {
132+ self . config . request_timeout
133+ }
120134}
121135
122136impl From < String > for Query {
You can’t perform that action at this time.
0 commit comments