mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 13:56:30 +03:00
sql: replace .get_conn() interface with .call()
.call() interface is safer because it ensures that blocking operations on SQL connection are called within tokio::task::block_in_place(). Previously some code called blocking operations in async context, e.g. add_parts() in receive_imf module. The underlying implementation of .call() can later be replaced with an implementation that does not require block_in_place(), e.g. a worker pool, without changing the code using the .call() interface.
This commit is contained in:
@@ -907,7 +907,8 @@ impl ChatId {
|
||||
|
||||
async fn parent_query<T, F>(self, context: &Context, fields: &str, f: F) -> Result<Option<T>>
|
||||
where
|
||||
F: FnOnce(&rusqlite::Row) -> rusqlite::Result<T>,
|
||||
F: Send + FnOnce(&rusqlite::Row) -> rusqlite::Result<T>,
|
||||
T: Send + 'static,
|
||||
{
|
||||
let sql = &context.sql;
|
||||
let query = format!(
|
||||
|
||||
Reference in New Issue
Block a user