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: implement retry mechanism for Discourse API requests #1307

Merged
merged 3 commits into from
Feb 25, 2025

Conversation

sasa-tomic
Copy link
Member

Added

  • Implemented a retry mechanism for sending requests to the Discourse API to handle TOO_MANY_REQUESTS errors by retrying with exponential backoff.

Updated

  • Modified existing request logic to encapsulate retry logic using a for loop.
  • Updated error handling to include retries upon request failures, with a max retry count of 5 and incremental sleep before each retry.
  • Included logging for rate limiting warnings and retry attempts.

Removed

  • Eliminated old match structure for direct request handling, replacing it with retry-inclusive logic.

Misc

  • Added unreachable!() statement to ensure code paths are handled explicitly.

- Introduce retry mechanism in `DiscourseClientImp` for handling rate-limiting and transient errors.
- Set maximum retries to 5 with exponential backoff (5 seconds * retry count).
- Warn on rate limiting and errors during retries.
- Ensure graceful exit with precise error handling for `NOT_FOUND` and other request errors.
- Add `unreachable!` safeguard to handle unexpected logic fall-through.
@sasa-tomic sasa-tomic self-assigned this Feb 25, 2025
@sasa-tomic sasa-tomic marked this pull request as ready for review February 25, 2025 14:10
@sasa-tomic sasa-tomic requested a review from a team as a code owner February 25, 2025 14:10
Copy link
Contributor

@DFINITYManu DFINITYManu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry gotta request another one I oversaw

@sasa-tomic sasa-tomic merged commit 6fabe7b into main Feb 25, 2025
5 checks passed
@sasa-tomic sasa-tomic deleted the feature/implement-retry-logic branch February 25, 2025 17:08
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.

2 participants