In my apps, I want to release failing jobs back to the tube with lower priority and with increasing delay.
A job already has all the necessary metadata, but I would love to avoid repeating the same calculations over and over.
Compact-ish version:
prio:=uint32(job.Stats.Releases) *job.Stats.Prioritydelay:=time.Duration(job.Stats.Releases) *job.Stats.Delayiferr:=job.ReleaseWithParams(ctx, prio, delay); err!=nil {
logger.Error("Failed to release a failing job", slog.Any("err", err))
}
returnExtended version:
delay:=time.Duration(job.Stats.Releases) *job.Stats.Delayifdelay>maxDelay { delay=maxDelay
}
prio:=uint32(job.Stats.Releases) *job.Stats.Priorityifprio>maxPrio { prio=maxPrio
}
iferr:=job.ReleaseWithParams(ctx, prio, delay); err!=nil {
logger.Error("Failed to release a failing job", slog.Any("job_stats", job.Stats), slog.Any("err", err),
)
}
returnI suggest adding a function that helps to delay a job with proper back-off settings:
It may look like this:
iferr:=job.ReleaseWithParams(ctx, job.BackoffParams(maxDelay)); err!=nil {
logger.Error("Failed to release a failing job", slog.Any("err", err))
}
returnI am curious to hear your thoughts. Maybe there is already something that I am missing.
In my apps, I want to release failing jobs back to the tube with lower priority and with increasing delay.
A job already has all the necessary metadata, but I would love to avoid repeating the same calculations over and over.
Compact-ish version:
Extended version:
I suggest adding a function that helps to delay a job with proper back-off settings:
It may look like this:
I am curious to hear your thoughts. Maybe there is already something that I am missing.