rhuffman / re-retrying

A Java library to allow for the creation of configurable retrying strategies for an arbitrary function call, such as something that communicates with a remote service with flaky uptime.
Apache License 2.0
35 stars 6 forks source link

For logging purposes, provide approximate delay until next retry #19

Open rhuffman opened 6 years ago

rhuffman commented 6 years ago

In a current project I have a RetryListener that provides debug output for each retry. I would really like for it to log when the next attempt will be made (if any). However, the Attempt does not contain that data.

A WaitStrategy, given the most recent failed Attempt, calculates the amount of time the Retryer should sleep before making another attempt. If the ResultAttempt and ExceptionAttempt took the WaitStrategy, the delay before the next retry could be calculated and saved as a field. Then the RetryListener could log that.