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 {
2121
2222 async fn transaction ( & self , tx_behavior : TransactionBehavior ) -> Result < Transaction > ;
2323
24+ fn interrupt ( & self ) -> Result < ( ) > ;
25+
2426 fn is_autocommit ( & self ) -> bool ;
2527
2628 fn changes ( & self ) -> u64 ;
@@ -185,6 +187,11 @@ impl Connection {
185187 self . conn . transaction ( tx_behavior) . await
186188 }
187189
190+ /// Cancel ongoing operations and return at earliest opportunity.
191+ pub fn interrupt ( & self ) -> Result < ( ) > {
192+ self . conn . interrupt ( )
193+ }
194+
188195 /// Check weather libsql is in `autocommit` or not.
189196 pub fn is_autocommit ( & self ) -> bool {
190197 self . conn . is_autocommit ( )
Original file line number Diff line number Diff line change @@ -163,6 +163,11 @@ impl Conn for HttpConnection<HttpSender> {
163163 } )
164164 }
165165
166+ fn interrupt ( & self ) -> crate :: Result < ( ) > {
167+ // Interrupt is a no-op for remote connections.
168+ Ok ( ( ) )
169+ }
170+
166171 fn is_autocommit ( & self ) -> bool {
167172 self . is_autocommit ( )
168173 }
@@ -343,6 +348,11 @@ impl Conn for HranaStream<HttpSender> {
343348 todo ! ( "sounds like nested transactions innit?" )
344349 }
345350
351+ fn interrupt ( & self ) -> crate :: Result < ( ) > {
352+ // Interrupt is a no-op for remote connections.
353+ Ok ( ( ) )
354+ }
355+
346356 fn is_autocommit ( & self ) -> bool {
347357 false // for streams this method is callable only when we're within explicit transaction
348358 }
Original file line number Diff line number Diff line change @@ -355,6 +355,11 @@ impl Connection {
355355 Transaction :: begin ( self . clone ( ) , tx_behavior)
356356 }
357357
358+ pub fn interrupt ( & self ) -> Result < ( ) > {
359+ unsafe { ffi:: sqlite3_interrupt ( self . raw ) } ;
360+ Ok ( ( ) )
361+ }
362+
358363 pub fn is_autocommit ( & self ) -> bool {
359364 unsafe { ffi:: sqlite3_get_autocommit ( self . raw ) != 0 }
360365 }
Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ impl Conn for LibsqlConnection {
5454 } )
5555 }
5656
57+ fn interrupt ( & self ) -> Result < ( ) > {
58+ self . conn . interrupt ( )
59+ }
60+
5761 fn is_autocommit ( & self ) -> bool {
5862 self . conn . is_autocommit ( )
5963 }
Original file line number Diff line number Diff line change @@ -503,6 +503,11 @@ impl Conn for RemoteConnection {
503503 } )
504504 }
505505
506+ fn interrupt ( & self ) -> Result < ( ) > {
507+ // Interrupt is a no-op for remote connections.
508+ Ok ( ( ) )
509+ }
510+
506511 fn is_autocommit ( & self ) -> bool {
507512 self . is_state_init ( )
508513 }
You can’t perform that action at this time.
0 commit comments