feat: exponential retry decorator #88
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a robust, configurable retry decorator with exponential backoff and rate-limit handling for both synchronous and asynchronous functions. It also integrates the retry decorator settings into the infrastructure configuration, making them easily adjustable via environment variables and Kubernetes ConfigMaps. Comprehensive tests have been added to ensure correct behavior. The main changes are grouped below:
Retry Decorator Implementation and Utilities
retry_with_backoff
decorator inlibs/rag-core-lib/src/rag_core_lib/impl/utils/retry_decorator.py
, supporting configurable retries, exponential backoff, jitter, and rate-limit awareness for sync/async functions.libs/rag-core-lib/src/rag_core_lib/impl/utils/utils.py
for parsing rate-limit headers, normalizing dictionaries, and extracting status codes/headers from exceptions.Configuration and Infrastructure Integration
RetryDecoratorSettings
inlibs/rag-core-lib/src/rag_core_lib/impl/settings/retry_decorator_settings.py
using Pydantic, allowing environment-based configuration of retry logic parameters.retryDecorator
configuration block toinfrastructure/rag/values.yaml
for setting retry parameters via Helm values.infrastructure/rag/templates/configmap.yaml
to expose retry decorator settings to Kubernetes deployments.admin-backend/deployment.yaml
,backend/deployment.yaml
) to mount the new retry decorator ConfigMap. [1] [2]_helpers.tpl
.Testing
libs/rag-core-lib/tests/retry_decorator_test.py
to validate retry logic, rate-limit handling, and configuration.This PR covers the following feature request
#87