Refactored retry config into _retry.py and added support for exponential backoff and Retry-After header#871
Conversation
lahirumaramba
left a comment
There was a problem hiding this comment.
Thanks Jonathan! Overall looking good! Added a few comments!
firebase_admin/_retry.py
Outdated
|
|
||
| def __init__( | ||
| self, | ||
| status: int = 10, |
There was a problem hiding this comment.
Would it make sense to call this max_retries instead?
There was a problem hiding this comment.
In the current state yes because status retries are our only retries we have. This was more of a future proof decision for when we added error retires where we would have total, status and error counters.
Similar to the placeholder comment I think we can use max_retries (and retries_left internally since we decrease this value) and add the other options later.
| response, error = None, None | ||
|
|
||
| try: | ||
| logger.debug('Sending request in _dispatch_with_retry(): %r', request) |
There was a problem hiding this comment.
Do we plan to keep these logs in the production code?
There was a problem hiding this comment.
I would want to keep these for future debugging. This would be helpful to catch issues as we iterate. Wdyt?
…or FCM async and HTTP/2 support (#882) * Added minimal support for sending FCM messages in async using HTTP/2 (#870) * httpx async_send_each prototype * Clean up code and lint * fix: Add extra dependancy for http2 * fix: reset message batch limit to 500 * fix: Add new import to `setup.py` * Refactored retry config into `_retry.py` and added support for exponential backoff and `Retry-After` header (#871) * Refactored retry config to `_retry.py` and added support for backoff and Retry-After * Added unit tests for `_retry.py` * Updated unit tests for HTTPX request errors * Address review comments * Added `HttpxAsyncClient` wrapper for `httpx.AsyncClient` and support for `send_each_for_multicast_async()` (#878) * Refactored retry config to `_retry.py` and added support for backoff and Retry-After * Added unit tests for `_retry.py` * Updated unit tests for HTTPX request errors * Add HttpxAsyncClient to wrap httpx.AsyncClient * Added forced refresh to google auth credential flow and fixed lint * Added unit tests for `GoogleAuthCredentialFlow` and `HttpxAsyncClient` * Removed duplicate export * Added support for `send_each_for_multicast_async()` and updated doc string and type hints * Remove duplicate auth class * Cover auth request error case when `requests` request fails in HTTPX auth flow * Update test for `send_each_for_multicast_async()` * Address review comments * fix lint and some types * Address review comments and removed unused code * Update metric header test logic for `TestHttpxAsyncClient` * Add `send_each_for_multicast_async` to `__all__` * Apply suggestions from TW review
Adds more retry logic support
This PR covers:
HttpxRetryTransportto_retry.pyHttpxRetryto manage retry stateHttpxRetryTransportcreationRetry-Afterheaders from request responsesHttpxRetryandHttpxRetryTransport