Implement Retry Strategy Resolver Pattern with Per-Client Caching #600
+258
−19
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.
Summary
Introduces a resolver pattern for retry strategies that enables per-client caching and state management. This allows multiple operations from the same client to share a single retry strategy instance, which is important for strategies that maintain state across retries such as token buckets and rate limiters.
Motivation
Previously, each operation created its own retry strategy instance, preventing state sharing across operations from the same client. This change implements a resolver-based approach.
Key Changes
RetryStrategyResolverprotocol similar toAuthSchemeResolver. This will be used for objects which will supply clients with retry strategiesCachingRetryStrategyResolverwhich implements the protocol and returns a unique instance of a requested retry strategy object per unique combination of client, max attempts setting, and retry mode settingCLIENT_IDproperty key to the context to allow the request pipeline to track the unique client object a request came fromRetryStrategyResolverwhere it had previously only used aRetryStrategyobject directlyRetryStrategyOptionsfor users to configure their retry strategy mode and max attempts per client callBreaking Changes
Customers directly supplying a
RetryStrategyobject will no longer be able to do so, and will need to pass aRetryStrategyResolverinstead. This is documented in the included changelogBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.