feat: add resilience layer for Authlete API calls (rate limit best practices)#87
Draft
meysam wants to merge 1 commit into
Draft
feat: add resilience layer for Authlete API calls (rate limit best practices)#87meysam wants to merge 1 commit into
meysam wants to merge 1 commit into
Conversation
…actices) Implements caching, conditional retry with exponential backoff and jitter, and per-endpoint circuit breakers with stale-cache fallback, as described in the Rate Limit Best Practices guide. All endpoints obtain the AuthleteApi client through a dynamic proxy wrapper; behavior is tunable via resilience.properties and can be disabled entirely with resilience.enabled=false.
CriGoT
reviewed
Jun 15, 2026
| { | ||
| // Common spellings of the rate-limit reset header, matched case-insensitively. | ||
| private static final String[] RESET_HEADERS = { | ||
| "RateLimit-Reset", "Ratelimit-Reset", "X-RateLimit-Reset", "Retry-After" |
There was a problem hiding this comment.
The findHeader method is performing a case insensitive comparison so I don't think we need to have two entries with different casing
Suggested change
| "RateLimit-Reset", "Ratelimit-Reset", "X-RateLimit-Reset", "Retry-After" | |
| "RateLimit-Reset", "X-RateLimit-Reset", "Retry-After" |
Comment on lines
+181
to
+193
| detail.append(req.getToken()); | ||
| detail.append('|').append(join(req.getScopes())); | ||
| detail.append('|').append(req.getSubject()); | ||
| detail.append('|').append(req.getClientCertificate()); | ||
| detail.append('|').append(req.getHtm()); | ||
| detail.append('|').append(req.getHtu()); | ||
| detail.append('|').append(join(req.getResources())); | ||
| detail.append('|').append(req.getUri()); | ||
| detail.append('|').append(req.getTargetUri()); | ||
| detail.append('|').append(join(req.getAcrValues())); | ||
| detail.append('|').append(req.getMaxAge()); | ||
| detail.append('|').append(req.isRequestBodyContained()); | ||
| detail.append('|').append(req.isDpopNonceRequired()); |
There was a problem hiding this comment.
Since we are excluding DPoP and HTTP message signature requests from caching we probably should not use the parameters intended for these requests such as: htu, htm, targetUri, isDpopNonceRequred and isRequestBodyContained
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements caching, conditional retry with exponential backoff and jitter, and per-endpoint circuit breakers with stale-cache fallback, as described in the Rate Limit Best Practices guide.
All endpoints obtain the AuthleteApi client through a dynamic proxy wrapper; behavior is tunable via resilience.properties and can be disabled entirely with resilience.enabled=false.