Replies: 1 comment 3 replies
-
Hmm, I think this might turn out to be quite complex for the user code. You'd end up having to internalize all the job failure code into your job's body wouldn't you? Like you wouldn't want to call it unless we're on I was going to suggest something like a new hook that you could use to plug into the last failure of a job, but that wouldn't provide transactional guarantees. Given this is a very specific use case, it might be more practical just to have a poll loop that looks for discarded jobs and which can be triggered preemptively through the use of a subscription (so it's low latency). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am looking and cannot find a good way to run a piece of code after the job finally fails (after multiple attempts, etc).
The use case here is that I have a web app and I want to offload work to a background job while the user waits for it.
JobCompleteTxinside a transaction to assure that job's state and row's status are always in sync.I was thinking about the following options:
JobCompleteTx. But that means that if I look at River's stats, such job will be counted as succeeded.So to me it looks like there is a need for
JobFailTxfunction which would be similar toJobCompleteTxbut it would mark job as failed?I also use
river.JobCancelfor errors when I know job has failed in a way that it makes no sense to retry. But there is no way to also inside same transaction update my row's status. So I think that approach withriver.JobCancelis not the best one. Probably we needJobCancelTxandJobFailTx.Or is there some other way?
Beta Was this translation helpful? Give feedback.
All reactions