mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-09 21:29:06 -05:00
improvement: move sqlite connection acquisition into blocking thread
This commit is contained in:
parent
cec501b37f
commit
3fcaf97a15
|
@ -282,9 +282,11 @@ impl NostrRepo for SqliteRepo {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let _write_guard = self.write_in_progress.lock().await;
|
let _write_guard = self.write_in_progress.lock().await;
|
||||||
// spawn a blocking thread
|
// spawn a blocking thread
|
||||||
let mut conn = self.write_pool.get()?;
|
//let mut conn = self.write_pool.get()?;
|
||||||
|
let pool = self.write_pool.clone();
|
||||||
let e = e.clone();
|
let e = e.clone();
|
||||||
let event_count = task::spawn_blocking(move || {
|
let event_count = task::spawn_blocking(move || {
|
||||||
|
let mut conn = pool.get()?;
|
||||||
SqliteRepo::persist_event(&mut conn, &e)
|
SqliteRepo::persist_event(&mut conn, &e)
|
||||||
}).await?;
|
}).await?;
|
||||||
self.metrics
|
self.metrics
|
||||||
|
|
Loading…
Reference in New Issue
Block a user