Package hudson.util
Class Retrier.Builder<V>
- java.lang.Object
-
- hudson.util.Retrier.Builder<V>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Retrier<V>build()Create a Retrier object with the specification set in this builder.Retrier.Builder<V>withAttempts(int attempts)Set the number of attempts trying to perform the action.Retrier.Builder<V>withDelay(long millis)Set the time in milliseconds to wait for the next attempt.Retrier.Builder<V>withDuringActionExceptionListener(BiFunction<Integer,Exception,V> exceptionListener)Set the listener to be executed when an allowed exception is raised when performing the action.Retrier.Builder<V>withDuringActionExceptions(Class<?>[] exceptions)Set all the exceptions that are allowed and indicate that the action was failed.
-
-
-
Constructor Detail
-
Builder
public Builder(@NonNull Callable<V> callable, @NonNull BiPredicate<Integer,V> checkResult, @NonNull String action)Constructor of the builder with the required parameters.- Parameters:
callable- Action to performcheckResult- Method to check if the result of the action was a successaction- name of the action to perform, for messages purposes.
-
-
Method Detail
-
withAttempts
@NonNull public Retrier.Builder<V> withAttempts(int attempts)
Set the number of attempts trying to perform the action.- Parameters:
attempts- number of attempts- Returns:
- this builder
-
withDelay
@NonNull public Retrier.Builder<V> withDelay(long millis)
Set the time in milliseconds to wait for the next attempt.- Parameters:
millis- milliseconds to wait- Returns:
- this builder
-
withDuringActionExceptions
@NonNull public Retrier.Builder<V> withDuringActionExceptions(@CheckForNull Class<?>[] exceptions)
Set all the exceptions that are allowed and indicate that the action was failed. When an exception of this type or a child type is raised, a listener can be called (withDuringActionExceptionListener(BiFunction)). In any case, the retrier continues its process, retrying to perform the action again, as it was a normal failure.- Parameters:
exceptions- exceptions that indicate that the action was failed.- Returns:
- this builder
-
withDuringActionExceptionListener
@NonNull public Retrier.Builder<V> withDuringActionExceptionListener(@NonNull BiFunction<Integer,Exception,V> exceptionListener)
Set the listener to be executed when an allowed exception is raised when performing the action. The listener could even change the result of the action if needed.- Parameters:
exceptionListener- the listener to call to- Returns:
- this builder
-
-