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
{{ message }}
Repository navigation
FR: Acknowledging jobs outside of worker function #685
Currently, the job is 'done' as long as worker.Work() returns.
I need a different approach similar to what AMQP supports where pulling a job is decoupled from acknowledging or not acknowledging it.
Ideally, some sort of AsyncWorker would help a lot, especially if it can be handled with channels. I.e something like:
consumeChan, err=riverClient.Consume(ctx, &river.ConsumeOpts{
// I'm not sure this makes sense here in case of pg notifyMaxPrefechCount: 10,
// Simimar to `RescueStuckJobsAfter`, nack the stuck jobs after a timeoutNackTimeout: time.Second*time.Duration(60)
})
gofunc() {
forasyncJob:=rangeconsumeChan {
processJob(asyncJob)
}
}()
funcprocessJob(asyncJob*river.AsyncJob[AsyncJobArgs]) {
// autonomous `worker.Work` behaviour// process the job ()// ...iferr!=nil {
_=asyncJob.JobSnooze(err)
// too many retries// _ = asyncJob.JobCancel(err)
}
err=asyncJob.JobComplete()
iferr!=nil {
log.Debug("failed to complete the job, channel is probably closed")
}
}
Activity