File tree Expand file tree Collapse file tree 5 files changed +31
-0
lines changed Expand file tree Collapse file tree 5 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ pub(crate) trait Conn {
21
21
22
22
async fn transaction ( & self , tx_behavior : TransactionBehavior ) -> Result < Transaction > ;
23
23
24
+ fn interrupt ( & self ) -> Result < ( ) > ;
25
+
24
26
fn is_autocommit ( & self ) -> bool ;
25
27
26
28
fn changes ( & self ) -> u64 ;
@@ -185,6 +187,11 @@ impl Connection {
185
187
self . conn . transaction ( tx_behavior) . await
186
188
}
187
189
190
+ /// Cancel ongoing operations and return at earliest opportunity.
191
+ pub fn interrupt ( & self ) -> Result < ( ) > {
192
+ self . conn . interrupt ( )
193
+ }
194
+
188
195
/// Check weather libsql is in `autocommit` or not.
189
196
pub fn is_autocommit ( & self ) -> bool {
190
197
self . conn . is_autocommit ( )
Original file line number Diff line number Diff line change @@ -163,6 +163,11 @@ impl Conn for HttpConnection<HttpSender> {
163
163
} )
164
164
}
165
165
166
+ fn interrupt ( & self ) -> crate :: Result < ( ) > {
167
+ // Interrupt is a no-op for remote connections.
168
+ Ok ( ( ) )
169
+ }
170
+
166
171
fn is_autocommit ( & self ) -> bool {
167
172
self . is_autocommit ( )
168
173
}
@@ -343,6 +348,11 @@ impl Conn for HranaStream<HttpSender> {
343
348
todo ! ( "sounds like nested transactions innit?" )
344
349
}
345
350
351
+ fn interrupt ( & self ) -> crate :: Result < ( ) > {
352
+ // Interrupt is a no-op for remote connections.
353
+ Ok ( ( ) )
354
+ }
355
+
346
356
fn is_autocommit ( & self ) -> bool {
347
357
false // for streams this method is callable only when we're within explicit transaction
348
358
}
Original file line number Diff line number Diff line change @@ -355,6 +355,11 @@ impl Connection {
355
355
Transaction :: begin ( self . clone ( ) , tx_behavior)
356
356
}
357
357
358
+ pub fn interrupt ( & self ) -> Result < ( ) > {
359
+ unsafe { ffi:: sqlite3_interrupt ( self . raw ) } ;
360
+ Ok ( ( ) )
361
+ }
362
+
358
363
pub fn is_autocommit ( & self ) -> bool {
359
364
unsafe { ffi:: sqlite3_get_autocommit ( self . raw ) != 0 }
360
365
}
Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ impl Conn for LibsqlConnection {
54
54
} )
55
55
}
56
56
57
+ fn interrupt ( & self ) -> Result < ( ) > {
58
+ self . conn . interrupt ( )
59
+ }
60
+
57
61
fn is_autocommit ( & self ) -> bool {
58
62
self . conn . is_autocommit ( )
59
63
}
Original file line number Diff line number Diff line change @@ -503,6 +503,11 @@ impl Conn for RemoteConnection {
503
503
} )
504
504
}
505
505
506
+ fn interrupt ( & self ) -> Result < ( ) > {
507
+ // Interrupt is a no-op for remote connections.
508
+ Ok ( ( ) )
509
+ }
510
+
506
511
fn is_autocommit ( & self ) -> bool {
507
512
self . is_state_init ( )
508
513
}
You can’t perform that action at this time.
0 commit comments