Skip to content

Commit bf8da1e

Browse files
committed
worker/jobs/typosquat: Replace r2d2 with deadpool
1 parent bf77a03 commit bf8da1e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/worker/jobs/typosquat.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
use anyhow::anyhow;
12
use std::sync::Arc;
23

34
use crates_io_worker::BackgroundJob;
45
use diesel::PgConnection;
56
use typomania::Package;
67

78
use crate::email::Email;
8-
use crate::tasks::spawn_blocking;
99
use crate::{
1010
typosquat::{Cache, Crate},
1111
worker::Environment,
@@ -34,12 +34,13 @@ impl BackgroundJob for CheckTyposquat {
3434
async fn run(&self, env: Self::Context) -> anyhow::Result<()> {
3535
let crate_name = self.name.clone();
3636

37-
spawn_blocking(move || {
38-
let mut conn = env.connection_pool.get()?;
39-
let cache = env.typosquat_cache(&mut conn)?;
40-
check(&env.emails, cache, &mut conn, &crate_name)
37+
let conn = env.deadpool.get().await?;
38+
conn.interact(move |conn| {
39+
let cache = env.typosquat_cache(conn)?;
40+
check(&env.emails, cache, conn, &crate_name)
4141
})
4242
.await
43+
.map_err(|err| anyhow!(err.to_string()))?
4344
}
4445
}
4546

0 commit comments

Comments
 (0)