Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix and improve rate limit handling. #176

Merged
merged 2 commits into from
Mar 14, 2025
Merged

feat: fix and improve rate limit handling. #176

merged 2 commits into from
Mar 14, 2025

Conversation

rhamzeh
Copy link
Member

@rhamzeh rhamzeh commented Mar 7, 2025

The SDK now respects the rate limit headers (Retry-After) returned by the server and will retry the request after the specified time. If the header is not sent: for 429s, it will fall back to exponential backoff. For 5xxs, it will fall back to exponential backoff if the request does not modify state.

Description

Generated from openfga/sdk-generator#506 pinned to this API commit: openfga/api@7c098f1, using

make build-client-go OPEN_API_REF=7c098f10acd22137c659c407818a4e0880044afe

References

Closes: #177
Generated from openfga/sdk-generator#506

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

@rhamzeh rhamzeh requested review from a team as code owners March 7, 2025 16:57
@codecov-commenter
Copy link

codecov-commenter commented Mar 7, 2025

Codecov Report

Attention: Patch coverage is 82.35294% with 18 lines in your changes missing coverage. Please review.

Project coverage is 24.98%. Comparing base (bbb95d9) to head (cf4bc2f).

Files with missing lines Patch % Lines
internal/utils/retryutils/retryparams.go 77.27% 5 Missing ⚠️
internal/utils/retryutils/retryutils.go 90.00% 4 Missing and 1 partial ⚠️
oauth2/token.go 40.00% 2 Missing and 1 partial ⚠️
configuration.go 80.00% 1 Missing and 1 partial ⚠️
credentials/credentials.go 0.00% 2 Missing ⚠️
oauth2/internal/token.go 90.00% 1 Missing ⚠️

❌ Your project status has failed because the head coverage (24.98%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #176      +/-   ##
==========================================
- Coverage   25.27%   24.98%   -0.30%     
==========================================
  Files         104      105       +1     
  Lines       12592    12734     +142     
==========================================
- Hits         3183     3181       -2     
- Misses       9145     9304     +159     
+ Partials      264      249      -15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The SDK now retries on network errors and the default retry handling has been fixed
for both the calls to the OpenFGA API and the API Token Issuer for those using ClientCredentials

The SDK now also respects the rate limit headers (`Retry-After`) returned by the server and will retry the request after the specified time.
If the header is not sent or on network errors, it will fall back to exponential backoff.
ewanharris
ewanharris previously approved these changes Mar 14, 2025
@rhamzeh rhamzeh closed this Mar 14, 2025
@rhamzeh rhamzeh reopened this Mar 14, 2025
@rhamzeh rhamzeh added this pull request to the merge queue Mar 14, 2025
Merged via the queue into main with commit 89788f4 Mar 14, 2025
11 checks passed
@rhamzeh rhamzeh deleted the feat/retry branch March 14, 2025 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve the retry strategy
3 participants