How bhanafee/retryhttp works
Project type and purpose
• This is a Java/Gradle extension library for Resilience4j that adds HTTP-aware retry logic based on status codes and Retry-After headers for jakarta.servlet.http.HttpServletResponse.
• It is not a standalone server or full-stack app but a drop-in resilience extension that client applications wire into their HTTP request pipelines.
File structure
• Top-level: Gradle build files (build.gradle, settings.gradle), GitHub CI configs, LICENSE, README.
• src/main/java/com/maybeitssquid/retry:
• RetryAfterParser – parses Retry-After header into a Duration
• RetryStatusCodes – defines which HTTP status codes warrant a retry
• LimitRetryAfter – predicate to block excessively long waits
• src/main/java/com/maybeitssquid/retry/resilience4j:
• HeedRetryAfter – an IntervalBiFunction that adjusts wait intervals according to parsed header
• Retry – factory methods that wire predicates + bulkhead functions into Resilience4j RetryConfig
• src/test mirrors production packages for unit tests.
README for additional insights
• The library provides two main capabilities:
a. Predicates for status-code-based retry decisions (idempotent vs non-idempotent)
b. Parsing & honoring of Retry-After headers via predicates and interval functions
• Integration points are through Resilience4j interfaces: Predicate<HttpServletResponse> and IntervalBiFunction<Duration, Integer>.
1. Client Application – issues HTTP calls
2. Resilience4j Core – provides Retry pattern interfaces
3. HTTP-Aware Retry Library
• Core Predicates (RetryStatusCodes, LimitRetryAfter)
• Header Parser (RetryAfterParser)
• Resilience4j Integration (HeedRetryAfter, Retry)
4. External HTTP Service – the target of requests
• Client App → Resilience4j Retry (configured via Retry.of(...) using our library’s Retry.createIdempotent(...) or similar)
• Resilience4j Retry wraps the HTTP request execution
• On each response, Retry core invokes our Predicate<HttpServletResponse>
• Predicate calls RetryStatusCodes for code check
• If a Retry-After header is present, Predicate defers to LimitRetryAfter + RetryAfterParser
• If header indicates a wait, HeedRetryAfter computes the delay and passes it to Resilience4j scheduler
• After backoff, Resilience4j retries the HTTP call → External HTTP Service
c. Architectural patterns & principles
• Decorator/Adapter: wrapping Resilience4j’s RetryConfig with HTTP-specific behavior
• Single Responsibility: separate modules for parsing, code-based logic, integration
• Open/Closed: users can supply custom clock or extended parser variations without modifying core logic
d. Key technologies & libs
• Java 17+ (Gradle build)
• Resilience4j core interfaces (Retry, IntervalBiFunction)
• Jakarta Servlet API (HttpServletResponse)