Class RetryManager
java.lang.Object
com.peterphi.std.guice.common.retry.retry.RetryManager
-
Constructor Summary
ConstructorDescriptionRetryManager
(BackoffStrategy strategy, int maxAttempts, com.codahale.metrics.Timer attempts, com.codahale.metrics.Meter attemptFailures) -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> T
finalAttemptFailed
(Retryable<T> operation, int attempt, boolean logError, Throwable e) Called when the final attempt at a retryable operation failedprotected boolean
maxAttemptsReached
(int attempt) Returns true if the given attempt number is greater than or equal to the maximum number of attempts this retry manager should run<T> T
<T> T
runUnchecked
(Retryable<T> operation) Run the operation, only throwing an unchecked exception on failure
-
Constructor Details
-
RetryManager
public RetryManager(BackoffStrategy strategy, int maxAttempts, com.codahale.metrics.Timer attempts, com.codahale.metrics.Meter attemptFailures)
-
-
Method Details
-
run
- Throws:
Exception
-
maxAttemptsReached
protected boolean maxAttemptsReached(int attempt) Returns true if the given attempt number is greater than or equal to the maximum number of attempts this retry manager should run- Parameters:
attempt
-- Returns:
-
finalAttemptFailed
protected <T> T finalAttemptFailed(Retryable<T> operation, int attempt, boolean logError, Throwable e) throws Exception Called when the final attempt at a retryable operation failed Allows extending classes to customise behaviour or throw custom exceptions- Parameters:
operation
- - the operation being attemptedattempt
- - the attempt number that failedlogError
- if true, log the failuree
- - the exception thrown when the operation failed- Throws:
Exception
-
runUnchecked
Run the operation, only throwing an unchecked exception on failure- Type Parameters:
T
-- Parameters:
operation
-- Returns:
- Throws:
RuntimeException
-