@@ -3,7 +3,8 @@ use std::{
33 env,
44} ;
55
6- use redis:: { aio:: MultiplexedConnection , AsyncCommands , RedisResult } ;
6+ use log:: error;
7+ use redis:: { aio:: MultiplexedConnection , RedisResult } ;
78use redis_work_queue:: { Item , KeyPrefix , WorkQueue } ;
89use sqlx:: { postgres:: PgPoolOptions , query, query_as, Pool , Postgres } ;
910use std:: time:: Duration ;
@@ -110,7 +111,7 @@ async fn work(job: &Item, db_pool: &Pool<Postgres>, pings: &PingClient) -> Resul
110111 }
111112 pings
112113 . send_join (
113- & driver. email . trim_end_matches ( "@csh.rit.edu" ) ,
114+ driver. email . trim_end_matches ( "@csh.rit.edu" ) ,
114115 & rider. name ,
115116 & event_name,
116117 )
@@ -124,7 +125,7 @@ async fn work(job: &Item, db_pool: &Pool<Postgres>, pings: &PingClient) -> Resul
124125 }
125126 pings
126127 . send_leave (
127- & driver. email . trim_end_matches ( "@csh.rit.edu" ) ,
128+ driver. email . trim_end_matches ( "@csh.rit.edu" ) ,
128129 & rider. name ,
129130 & event_name,
130131 )
@@ -152,11 +153,15 @@ async fn work(job: &Item, db_pool: &Pool<Postgres>, pings: &PingClient) -> Resul
152153 }
153154 pings
154155 . send_remove (
155- & user. email . trim_end_matches ( "@csh.rit.edu" ) ,
156+ user. email . trim_end_matches ( "@csh.rit.edu" ) ,
156157 & driver. name ,
157158 & event_name,
158159 )
159- . await ;
160+ . await
161+ . map_err ( |err| RedisError {
162+ msg : format ! ( "Failed to send message: {}" , err) ,
163+ should_retry : true ,
164+ } ) ?;
160165 }
161166 for added in new_set. difference ( & old_set) {
162167 let user = user_map. get ( added) . unwrap ( ) ;
@@ -165,11 +170,15 @@ async fn work(job: &Item, db_pool: &Pool<Postgres>, pings: &PingClient) -> Resul
165170 }
166171 pings
167172 . send_add (
168- & user. email . trim_end_matches ( "@csh.rit.edu" ) ,
173+ user. email . trim_end_matches ( "@csh.rit.edu" ) ,
169174 & driver. name ,
170175 & event_name,
171176 )
172- . await ;
177+ . await
178+ . map_err ( |err| RedisError {
179+ msg : format ! ( "Failed to send message: {}" , err) ,
180+ should_retry : true ,
181+ } ) ?;
173182 }
174183 }
175184 }
@@ -195,10 +204,11 @@ pub async fn work_loop(
195204 }
196205 // Drop a job that should be retried - it will be returned to the work queue after
197206 // the (5 second) lease expires.
198- Err ( err) if err. should_retry => ( ) ,
207+ Err ( err) if err. should_retry => error ! ( "{}" , err . msg ) ,
199208 // Errors that shouldn't cause a retry should mark the job as complete so it isn't
200209 // tried again.
201210 Err ( err) => {
211+ error ! ( "{}" , err. msg) ;
202212 work_queue. complete ( & mut db, & job) . await ?;
203213 }
204214 }
0 commit comments