@@ -9,10 +9,11 @@ use std::{error::Error, fs::read_to_string, path::Path, process::exit, rc::Rc};
9
9
use futures:: stream:: StreamExt ;
10
10
use typedb_driver:: {
11
11
answer:: { QueryAnswer , QueryType } ,
12
- TransactionType ,
12
+ TransactionOptions , TransactionType ,
13
13
} ;
14
14
15
15
use crate :: {
16
+ constants:: DEFAULT_TRANSACTION_TIMEOUT ,
16
17
printer:: { print_document, print_row} ,
17
18
repl:: command:: { parse_one_query, CommandResult , ReplError } ,
18
19
transaction_repl, ConsoleContext ,
@@ -155,7 +156,9 @@ pub(crate) fn transaction_read(context: &mut ConsoleContext, input: &[String]) -
155
156
let db_name_owned = db_name. clone ( ) ;
156
157
let transaction = context
157
158
. background_runtime
158
- . run ( async move { driver. transaction ( db_name_owned, TransactionType :: Read ) . await } )
159
+ . run ( async move {
160
+ driver. transaction_with_options ( db_name_owned, TransactionType :: Read , default_transaction_options ( ) ) . await
161
+ } )
159
162
. map_err ( |err| Box :: new ( err) as Box < dyn Error + Send > ) ?;
160
163
context. transaction = Some ( ( transaction, false ) ) ;
161
164
let repl = transaction_repl ( db_name, TransactionType :: Read ) ;
@@ -169,7 +172,9 @@ pub(crate) fn transaction_write(context: &mut ConsoleContext, input: &[String])
169
172
let db_name_owned = db_name. clone ( ) ;
170
173
let transaction = context
171
174
. background_runtime
172
- . run ( async move { driver. transaction ( db_name_owned, TransactionType :: Write ) . await } )
175
+ . run ( async move {
176
+ driver. transaction_with_options ( db_name_owned, TransactionType :: Write , default_transaction_options ( ) ) . await
177
+ } )
173
178
. map_err ( |err| Box :: new ( err) as Box < dyn Error + Send > ) ?;
174
179
context. transaction = Some ( ( transaction, false ) ) ;
175
180
let repl = transaction_repl ( db_name, TransactionType :: Write ) ;
@@ -183,7 +188,9 @@ pub(crate) fn transaction_schema(context: &mut ConsoleContext, input: &[String])
183
188
let db_name_owned = db_name. clone ( ) ;
184
189
let transaction = context
185
190
. background_runtime
186
- . run ( async move { driver. transaction ( db_name_owned, TransactionType :: Schema ) . await } )
191
+ . run ( async move {
192
+ driver. transaction_with_options ( db_name_owned, TransactionType :: Schema , default_transaction_options ( ) ) . await
193
+ } )
187
194
. map_err ( |err| Box :: new ( err) as Box < dyn Error + Send > ) ?;
188
195
context. transaction = Some ( ( transaction, false ) ) ;
189
196
let repl = transaction_repl ( db_name, TransactionType :: Schema ) ;
@@ -307,6 +314,10 @@ pub(crate) fn transaction_query(context: &mut ConsoleContext, input: &[impl AsRe
307
314
}
308
315
}
309
316
317
+ fn default_transaction_options ( ) -> TransactionOptions {
318
+ TransactionOptions :: new ( ) . transaction_timeout ( DEFAULT_TRANSACTION_TIMEOUT )
319
+ }
320
+
310
321
const QUERY_TYPE_TEMPLATE : & ' static str = "<QUERY TYPE>" ;
311
322
const QUERY_COMPILATION_SUCCESS : & ' static str = "Finished <QUERY TYPE> query validation and compilation..." ;
312
323
const QUERY_WRITE_FINISHED_STREAMING_ROWS : & ' static str = "Finished writes. Streaming rows..." ;
0 commit comments