Skip to content

Commit 40ddb4a

Browse files
Add explanation for why an attempt is always made
1 parent 3e6cf64 commit 40ddb4a

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

docs/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
smartquotes = False
2525
nitpicky = True
2626

27+
# -- Markdown configuration -----------------------------------------------
28+
29+
myst_enable_extensions = [
30+
"colon_fence"
31+
]
32+
2733
# -- Options for HTML output ----------------------------------------------
2834

2935
html_theme = "furo"

docs/source-2.0/guides/client-guidance/retries.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public interface RetryStrategy {
6161
/**
6262
* Invoked before the first request attempt.
6363
*
64+
* <p>An initial request will be made even if a token cannot be acquired.
65+
* It is recommended to always return a token so that the retry strategy
66+
* may continue to track each request and be informed when they succeed or
67+
* fail.
68+
*
6469
* @throws TokenAcquisitionFailedException if a token cannot be acquired.
6570
*/
6671
RetryToken acquireInitialToken();
@@ -99,7 +104,9 @@ to prevent race conditions.
99104

100105
An initial retry token should be acquired at the beginning of a request, before
101106
the first attempt is made. If an initial token cannot be acquired, the client
102-
should still make an attempt.
107+
should still make an attempt. This initial attempt is always made because the
108+
purpose of the retry strategy is to manage retries, not to gate access to a
109+
service entirely.
103110

104111
If an attempt fails, the retry strategy is passed the retry token for the
105112
attempt and given the exception raised by the attempt. If the retry strategy
@@ -407,7 +414,7 @@ demonstrate some of the potential needs of a retry system.
407414

408415
The following is an example retry strategy that implements exponential backoff
409416
with jitter alongside a token bucket. This strategy adds extra cost for timeout
410-
errors since they may indicate a more highly degraded service.
417+
errors since they may indicate a more degraded service.
411418

412419
Aside from delay, the retry token also tracks the number of attempts that have
413420
been made. This is necessary because this strategy imposes a maximum attempt
@@ -557,7 +564,7 @@ public final class AwsStandardRetryStrategy implements RetryStrategy {
557564
synchronized (tokensLock) {
558565
// When a successful request is made, refill the token bucket unless it
559566
// is already at maximum capacity.
560-
if (this.tokens < MAX_CAPACITY) {
567+
if (this.tokens <= MAX_CAPACITY - SUCCESS_REFUND) {
561568
this.tokens += SUCCESS_REFUND;
562569
}
563570
}

0 commit comments

Comments
 (0)