You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see that you can set an error handler for each JobRegistry, I'm wondering what's the idiomatic way to handle error for each NamedJob, it cannot be done on the error handler of JobRegistry, since the function signature does not have CurrentJob (you can wrap it in the error, but that's not ergonomic).
One way to do this: (very rough draft)
#[job(
name = "...",
error_handler = my_error_handler
)]
async fn my_job(...)
async fn my_error_handler(
tx: DbTransaction,
current_job: _,
err: SomeError,
is_error_final: bool // Is this the last attempt for this job?
) -> Result<....> {
...
}
Another way: (very rough draft)
#[job(
name = "...",
)]
async fn my_job(
current_job: _,
times_already_tried: u32,
total_allowed_tries: u32,
) -> Result<()> {
if times_already_tried >= total_allowed_tries {
// do something to handle the error,
// this implies that total_allowed_tries is not enforced by sqlxmq
current_job.complete().await?;
}
}
Any thoughts?
The text was updated successfully, but these errors were encountered:
Thanks for the awesome library.
I see that you can set an error handler for each
JobRegistry
, I'm wondering what's the idiomatic way to handle error for eachNamedJob
, it cannot be done on the error handler ofJobRegistry
, since the function signature does not haveCurrentJob
(you can wrap it in the error, but that's not ergonomic).One way to do this: (very rough draft)
Another way: (very rough draft)
Any thoughts?
The text was updated successfully, but these errors were encountered: