WIP: Retry with a custom function
NOTE: The lint tests are currently failing because of a change introduced in Ruff 0.3 which is incompatible with our flake8 set-up. We should solve this issue in a separate PR.
Description
This PR adds the possibility for users to configure Retry and Timeout policies for both grpc and http based clients.
Issue reference
https://github.com/dapr/python-sdk/issues/676
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list:
- [X] Code compiles correctly
- [X] Created/updated tests
- [ ] Extended the documentation
Codecov Report
Attention: Patch coverage is 88.07947% with 18 lines in your changes are missing coverage. Please review.
Project coverage is 86.34%. Comparing base (
fc0e9d1) to head (f98f36c). Report is 21 commits behind head on main.
| Files | Patch % | Lines |
|---|---|---|
| dapr/clients/retry.py | 82.71% | 14 Missing :warning: |
| dapr/conf/__init__.py | 50.00% | 2 Missing :warning: |
| dapr/actor/client/proxy.py | 50.00% | 1 Missing :warning: |
| dapr/aio/clients/grpc/client.py | 90.90% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #679 +/- ##
==========================================
- Coverage 86.37% 86.34% -0.03%
==========================================
Files 79 84 +5
Lines 4094 4306 +212
==========================================
+ Hits 3536 3718 +182
- Misses 558 588 +30
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
The lint tests are currently failing because of a change introduced in Ruff 0.3 which is incompatible with our flake8 set-up. We should solve this issue in a separate PR.
Is this PR ready @elena-kolevska ?
I kept the ruff version at 0.2.2 for now. Lint and Ruff are passing with that.
It's almost ready, I just wanted to confirm a few things with you:
- Right now the code will retry if the env variable is set, with no additional code changes. I also made it possible for users to tune other retry-related parameters (like initial_backoff, max_backoff, retryable_http_status_codes for ex.). Do you think the need ffor it justifies the added code complexity, and heavier constructors?
- For now, I only added the retry wrapper to one method, the
save_stateone. Once we confirm this is the right approach, I'll update all methods in the class. - When I first started work on this PR I added a timeout interceptor that would be applied to all calls. Looking at it now, I think it makes more sense to be able to specify a timeout per method. Some things are expected to take longer than others, and control should be more granular. What do you think?