aws / aws-sdk-java-v2

The official AWS SDK for Java - Version 2
Apache License 2.0
2.12k stars 802 forks source link

Allow RetryStrategy to use information from RetryPolicyContext in BackoffStrategy #5303

Closed awehrung closed 1 week ago

awehrung commented 1 week ago

Describe the feature

The new BackoffStrategy used by RetryStrategy should allow the method computeDelay to rely on more information than just the running attempt count, as does the old one used by RetryPolicy.

Use Case

While trying to switch from the now deprecated RetryPolicy to a RetryStrategy-based client, I noticed that I am unable to keep the same behaviour because my custom ...retry.backoff.BackoffStrategy::computeDelayBeforeNextRetry implementation relies on the RetryPolicyContext to decide on the actual duration and log some stuff as a side effect. The replacement ...retries.api.BackoffStrategy::computeDelay only allows access to the running attempt count.

Proposed Solution

As RetryPolicyContext has not been yet deprecated, I hope it still fits with the new RetryStrategy concept somehow.

Other Information

I may be doing this very wrong. In that case, kindly redirect me to the correct solution.

Acknowledgements

AWS Java SDK version used

2.26.3

JDK version used

openjdk version "22.0.1" 2024-04-16

Operating System and version

Ubuntu 22.04.1

sugmanue commented 1 week ago

Hi @awehrung

One of the objectives of the new retry strategies design is to decouple it from the sdk-core and aws-core package, and as part of this we won't be adding back that coupling. You can still use the RetryPolicy classes for your use case, those will be still supported for the foreseeable future.

sugmanue commented 1 week ago

Won't fix for the reasons give above.

github-actions[bot] commented 1 week ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.