Skip to content

Commit

Permalink
chore: attempt Send/Sync-compatibility for JS transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Jul 29, 2024
1 parent 5e7db17 commit 3fabd89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions query-engine/driver-adapters/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ macro_rules! impl_send_sync_on_wasm {

// Assume the proxy object will not be sent to service workers, we can unsafe impl Send + Sync.
impl_send_sync_on_wasm!(TransactionProxy);
impl_send_sync_on_wasm!(JsTransaction);
impl_send_sync_on_wasm!(TransactionContextProxy);
impl_send_sync_on_wasm!(JsTransactionContext);
impl_send_sync_on_wasm!(DriverProxy);
impl_send_sync_on_wasm!(CommonProxy);
impl_send_sync_on_wasm!(JsTransaction);
impl_send_sync_on_wasm!(JsTransactionContext);
10 changes: 8 additions & 2 deletions query-engine/driver-adapters/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::future::Future;

use async_trait::async_trait;
use metrics::decrement_gauge;
use quaint::{
Expand All @@ -22,9 +24,13 @@ impl JsTransactionContext {
Self { inner, tx_ctx_proxy }
}

pub async fn start_transaction(&self) -> quaint::Result<Box<JsTransaction>> {
self.tx_ctx_proxy.start_transaction().await
pub fn start_transaction(&self) -> UnsafeFuture<impl Future<Output = quaint::Result<Box<JsTransaction>>> + '_> {
UnsafeFuture(self.tx_ctx_proxy.start_transaction())
}

// pub async fn start_transaction(&self) -> quaint::Result<Box<JsTransaction>> {
// self.tx_ctx_proxy.start_transaction().await
// }
}

#[async_trait]
Expand Down

0 comments on commit 3fabd89

Please sign in to comment.