File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -235,8 +235,9 @@ pub async fn schedule_job(
235235 Ok ( ( ) )
236236}
237237
238- pub async fn run_scheduled_jobs ( ctx : & Context , db : & DbClient ) -> anyhow:: Result < ( ) > {
239- let jobs = get_jobs_to_execute ( & db) . await . unwrap ( ) ;
238+ pub async fn run_scheduled_jobs ( ctx : & Context ) -> anyhow:: Result < ( ) > {
239+ let db = & ctx. db . get ( ) . await ;
240+ let jobs = get_jobs_to_execute ( & db) . await ?;
240241 tracing:: trace!( "jobs to execute: {:#?}" , jobs) ;
241242
242243 for job in jobs. iter ( ) {
Original file line number Diff line number Diff line change @@ -401,13 +401,12 @@ fn spawn_job_runner(ctx: Arc<Context>) {
401401 loop {
402402 let ctx = ctx. clone ( ) ;
403403 let res = task:: spawn ( async move {
404- let pool = db:: ClientPool :: new ( ) ;
405404 let mut interval =
406405 time:: interval ( time:: Duration :: from_secs ( JOB_PROCESSING_CADENCE_IN_SECS ) ) ;
407406
408407 loop {
409408 interval. tick ( ) . await ;
410- db:: run_scheduled_jobs ( & ctx, & * pool . get ( ) . await )
409+ db:: run_scheduled_jobs ( & ctx)
411410 . await
412411 . context ( "run database scheduled jobs" )
413412 . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments