Skip to content

Commit 841c9fa

Browse files
authored
worker: Inline connection() fn (#8384)
1 parent 2e52b57 commit 841c9fa

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

crates/crates_io_worker/src/runner.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::worker::Worker;
44
use crate::{storage, BackgroundJob};
55
use anyhow::anyhow;
66
use diesel::prelude::*;
7-
use diesel::r2d2::{ConnectionManager, Pool, PoolError, PooledConnection};
7+
use diesel::r2d2::{ConnectionManager, Pool};
88
use futures_util::future::join_all;
99
use std::collections::HashMap;
1010
use std::sync::Arc;
@@ -16,7 +16,6 @@ use tracing::{info, info_span, warn, Instrument};
1616
const DEFAULT_POLL_INTERVAL: Duration = Duration::from_secs(1);
1717

1818
pub type ConnectionPool = Pool<ConnectionManager<PgConnection>>;
19-
pub type PooledConn = PooledConnection<ConnectionManager<PgConnection>>;
2019

2120
/// The core runner responsible for locking and running jobs
2221
pub struct Runner<Context> {
@@ -99,16 +98,13 @@ impl<Context: Clone + Send + Sync + 'static> Runner<Context> {
9998
RunHandle { handles }
10099
}
101100

102-
pub fn connection(&self) -> Result<PooledConn, PoolError> {
103-
self.connection_pool.get()
104-
}
105-
106101
/// Check if any jobs in the queue have failed.
107102
///
108103
/// This function is intended for use in tests and will return an error if
109104
/// any jobs have failed.
110105
pub fn check_for_failed_jobs(&self) -> anyhow::Result<()> {
111-
let failed_jobs = storage::failed_job_count(&mut *self.connection()?)?;
106+
let mut conn = self.connection_pool.get()?;
107+
let failed_jobs = storage::failed_job_count(&mut conn)?;
112108
if failed_jobs == 0 {
113109
Ok(())
114110
} else {

0 commit comments

Comments
 (0)