[Feature Proposal] [ActiveJob] Allow unlimited retry_on attempts

I would like to propose an addition to the ActiveJob retry_on API to allow the attempts argument to be the symbol ‘:unlimited’ in addition to the specific number of retry attempts that it allows today.

The code change required would be minimal, likely only requiring changing the test in activejob/exceptions.rb to see whether a retry should be called to if attempts == :unlimited || executions < attempts.

It seems this would be most valuable when dealing with infrastructure issues that are expected to recover and the alternative would be taking manual intervention to re-enqueue the job once the issue is fixed. Presently, you could just choose an arbitrarily high number of allowed attempts but that seems somewhat artificial and inexpressive.

Totally, I’ve wanted this recently too. I hacked it with: retry_on Error, wait: 10.seconds, attempts: Float::INFINITY.

I don’t necessarily like the unlimited name, but we can figure that out. Depending on how it reads, could also consider adding a retry_forever method.

PR to implement this: `retry_on` parameter `attempts` now accepts `:unlimited` by djmortonShopify · Pull Request #41761 · rails/rails · GitHub

I couldn’t think of a symbol that sounded better than :unlimited but I’m certainly open to suggestions.

A lot of older software uses 0 as the signal for “keep trying forever”. Not sure if that’s just familiar or intuitive.