Skip to content

Enable customizing runtime used for spawning blocking tasks inside the SyncConnectionWrapper #236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

bwqr
Copy link

@bwqr bwqr commented May 23, 2025

This PR adds a generic argument to SyncConnectionWrapper struct to let users decide which runtime they would like to use for spawning blocking tasks while calling underlying connection's methods. The PR also defines Tokio as the default runtime to both ease the usage and also to prevent causing a breaking change.

With that change, users can use Sqlite connection wrapped with SyncConnectionWrapper on wasm32-unknown-unknown target as tokio does not support running on this target.

It resolves #233. Even though initial attempt was to provide BatchInsert support for Sqlite connections wrapped with SyncConnectionWrapper, it is considered too much work to accomplish it. Instead of that, letting user access the inner connection and run BatchInsert queries with that connection was much more reasonable, since this also allows any other unsupported queries to be executed with inner connection.

bwqr added 3 commits May 23, 2025 16:19
Similar to `BlockOn` trait defined inside `src/async_connection_wrapper.rs`,
a `SpawnBlocking` trait will be introduced. Before introducing the trait,
move the defined structs into `implementation` module.
…locking tasks.

Previously, `SyncConnectionWrapper` was using tokio as spawning and running blocking
tasks. This had prevented using Sqlite backend on wasm32-unknown-unknown target since
futures generally run on top of JavaScript promises with the help of wasm_bindgen_futures
crate. It is now possible for users to provide their own runtime to spawn blocking tasks
inside the `SyncConnectionWrapper`.
@bwqr bwqr changed the title Enable customizing runtime used for spawn blocking tasks inside the SyncConnectionWrapper Enable customizing runtime used for spawning blocking tasks inside the SyncConnectionWrapper May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant