What does the @TimeLimiter
annotation exactly?
Example
@TimeLimiter(name = "abc123")
public <T> CompletableFuture<T> execute(Supplier<T> supplier) {
return CompletableFuture.supplyAsync(supplier);
}
Could be equal to:
public <T> CompletableFuture<T> execute(Supplier<T> supplier) {
TimeLimiter timeLimiter = timeLimiterRegistry.timeLimiter("abc123");
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(3); // This scheduler must somehow exist with the annotation as well right?
return timeLimiter.executeCompletionStage(
scheduler, () -> CompletableFuture.supplyAsync(supplier)).toCompletableFuture();
}
The scheduler required in the non-blocking variant of the code, is that somehow involved in the annotation?
Research
I've mainly read:
- Resilience4J's Guide on TimeLimiter
- Reflectoring's blog post Implementing Timeouts with Resilience4j
Is there some other place where I can understand what the annotation does?