-
In https://riverqueue.com/docs/reliable-workers and https://riverqueue.com/docs/transactional-job-completion it's mentioned that "Normally, jobs are marked complete out-of-band from the work functions of those jobs", but it's not exactly clear how that happens. I see https://github.com/riverqueue/river/blob/65fd8158aa6c4dd51558bb62cc4b3ce0f74de47a/internal/jobcompleter/job_completer.go is where things are happening, but what I am confused about is, if the worker doesn't mark the job as completed how does the job completer even is supposed to know that it's actually complete i.e transactional-job-completion seems like a necessity? I am reading job_completer.go more to understand better |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
EDIT: riverqueue.com/docs/subscriptions Ah, I think subscriptions is what it is. |
Beta Was this translation helpful? Give feedback.
-
The "completer" concept is there to mark jobs complete outside of the main execution / The design for River is at-least-once so you always need to be prepared for your jobs to potentially attempt execution more than once. In practice it should be very rare for a job to finish executing but fail to have its result saved to the database. In cases where you want to be sure this does not happen (say you are making other related database changes anyway) you can use |
Beta Was this translation helpful? Give feedback.
The "completer" concept is there to mark jobs complete outside of the main execution /
Work()
function call. In the normal case this is done async from the job itself finishing, and furthermore it is batched to significantly improve total throughput.The design for River is at-least-once so you always need to be prepared for your jobs to potentially attempt execution more than once. In practice it should be very rare for a job to finish executing but fail to have its result saved to the database. In cases where you want to be sure this does not happen (say you are making other related database changes anyway) you can use
JobCompleteTx
to ensure that those changes happen atomically with th…