Package dev.failsafe.internal
Class RateLimiterExecutor<R>
- java.lang.Object
-
- dev.failsafe.spi.PolicyExecutor<R>
-
- dev.failsafe.internal.RateLimiterExecutor<R>
-
- Type Parameters:
R
- result type
public class RateLimiterExecutor<R> extends PolicyExecutor<R>
A PolicyExecutor that handles failures according to aRateLimiter
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.time.Duration
maxWaitTime
private RateLimiterImpl<R>
rateLimiter
-
Constructor Summary
Constructors Constructor Description RateLimiterExecutor(RateLimiterImpl<R> rateLimiter, int policyIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ExecutionResult<R>
preExecute()
Called before execution to return an alternative result or exception such as if execution is not allowed or needed.protected java.util.concurrent.CompletableFuture<ExecutionResult<R>>
preExecuteAsync(Scheduler scheduler, FailsafeFuture<R> future)
Called before an async execution to return an alternative result or exception such as if execution is not allowed or needed.-
Methods inherited from class dev.failsafe.spi.PolicyExecutor
apply, applyAsync, getPolicyIndex, isFailure, onFailure, onFailureAsync, onSuccess, postExecute, postExecuteAsync
-
-
-
-
Field Detail
-
rateLimiter
private final RateLimiterImpl<R> rateLimiter
-
maxWaitTime
private final java.time.Duration maxWaitTime
-
-
Constructor Detail
-
RateLimiterExecutor
public RateLimiterExecutor(RateLimiterImpl<R> rateLimiter, int policyIndex)
-
-
Method Detail
-
preExecute
protected ExecutionResult<R> preExecute()
Description copied from class:PolicyExecutor
Called before execution to return an alternative result or exception such as if execution is not allowed or needed.- Overrides:
preExecute
in classPolicyExecutor<R>
-
preExecuteAsync
protected java.util.concurrent.CompletableFuture<ExecutionResult<R>> preExecuteAsync(Scheduler scheduler, FailsafeFuture<R> future)
Description copied from class:PolicyExecutor
Called before an async execution to return an alternative result or exception such as if execution is not allowed or needed. Returnsnull
if pre execution is not performed. If the resulting future is completed with anon-result
, then execution and post-execution should still be performed. If the resulting future is completed withnull
, then the execution is assumed to have been cancelled.- Overrides:
preExecuteAsync
in classPolicyExecutor<R>
-
-