A time limiter caps how long a client waits for a remote response. When the timeout is exceeded, the call fails, helping protect latency SLOs and limiting time spent waiting. section 8.2.4
Use it for synchronous provider calls, including those made during API composition. A timeout enables fail-fast behavior; returning a useful response when a provider is unavailable requires a separate fallback strategy. section 12.3.3
Listing 8.2 In a Spring Boot application, Resilience4j can be used by annotating client proxy methods. Method calls are intercepted by Spring AOP and wrapped with resiliency logic.
class OsoAuthorizer {
@CircuitBreaker(name = "osoAuthorizer")
@TimeLimiter(name = "osoAuthorizer")
@Retry(name = "osoAuthorizer", fallbackMethod = "isAuthorizedFallback")
public CompletableFuture<Boolean> isAuthorized(String user, String action, String securitySystem) {
...
}
private CompletableFuture<Boolean> isAuthorizedFallback(String user, String action, String securitySystem, Exception exception) {
return CompletableFuture.completedFuture(false);
}
See a Spring Boot client proxy annotated with Resilience4j’s @TimeLimiter alongside circuit-breaker and retry annotations. section 8.2.4
