[Question] Is it possible to override the "maxRetries" and "delay" of retry policy at runtime?
mjalvarez opened this issue · 2 comments
If I already created a retry policy of, say, maxRetries=3
and delay=300
, would it be possible to override that config based on the exception encountered at runtime?
For example, a CustomRuntimeException
with properties maxRetries=2
and delay=500
could override the current retry policy when thrown, such that the next attempt will be after 500ms, and that when every other Exception is encountered, the original retry policy will take effect.
You can't currently override maxRetries
, but you can use FailsafeExecutor.get(ContextualSupplier<>)
to make decisions about when to stop retrying based on execution Context..
You can use RetryPolicyBuilder.withDelayFn(ContextualSupplier<>)
to decisions about how long to delay based on execution context.