-
Notifications
You must be signed in to change notification settings - Fork 3
VED-240 Handle-PDS-Rate-Limit #1174
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
base: master
Are you sure you want to change the base?
Conversation
|
This branch is working on a ticket in the NHS England VED JIRA Project. Here's a handy link to the ticket: VED-240 |
…ital/immunisation-fhir-api into VED-240-handle-rate-limit
…ital/immunisation-fhir-api into VED-240-handle-rate-limit
…ital/immunisation-fhir-api into VED-240-handle-rate-limit
|
|
|
||
|
|
||
| def request_with_retry_backoff( | ||
| url: str, headers: dict, *, timeout: int = 5, max_retries: int = 2, backoff_seconds: float = 0.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put these default values somewhere as constants?
| # Ensure retryable codes include 429/5xx only (example) | ||
| with patch.object(Constants, "RETRYABLE_STATUS_CODES", {429, 500, 502, 503, 504}): | ||
| # Act | ||
| resp = request_with_retry_backoff("http://example.com", {}, max_retries=2, backoff_seconds=0.5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're using the default values for max_retries and backoff_seconds each time we call request_with_retry_backoff() here - should we just leave them out?
| } | ||
| response = requests.get(f"{self.base_url}/{patient_id}", headers=request_headers, timeout=5) | ||
| response = request_with_retry_backoff( | ||
| f"{self.base_url}/{patient_id}", headers=request_headers, timeout=5, max_retries=2, backoff_seconds=0.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're using the default values for timeout, max_retries and backoff_seconds here - should we just leave them out?



Summary
Implemented improved HTTP error handling and retry logic for PDS client integration to support clearer failure diagnostics and resilience against transient downstream failures.
Also made the mns error handling function reusable and moved to shared, so it can be re-used for PDS
Reviews Required
Review Checklist
ℹ️ This section is to be filled in by the reviewer.