Skip to content

Commit 3c9cb06

Browse files
authored
docs: Update RetrySettings javadocs to include polling (#1863)
* docs: Update RetrySettings to include LRO defaults * docs: Add poll verbiage to the docs * docs: Add info about Zero RPC timeout * docs: Update docs per PR feedback * docs: Update docs per PR feedback
1 parent 80f23ec commit 3c9cb06

File tree

1 file changed

+163
-55
lines changed

1 file changed

+163
-55
lines changed

gax-java/gax/src/main/java/com/google/api/gax/retrying/RetrySettings.java

+163-55
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
* <p>Server streaming RPCs interpret RPC timeouts a bit differently. For server streaming RPCs, the
6767
* RPC timeout gets converted into a wait timeout {@link
6868
* com.google.api.gax.rpc.ApiCallContext#withStreamWaitTimeout(Duration)}.
69+
*
70+
* <p>In Cloud Client Libraries, Retry and LRO Retry Settings may be configured for each RPC in a
71+
* service. These values are chosen by the service teams and may be found by looking at the
72+
* {Service}StubSettings.java file in each library. The default values listed below for each
73+
* configuration are the default values for the RetrySettings class if there are no RPC specific
74+
* configurations from the Service Team.
6975
*/
7076
@AutoValue
7177
public abstract class RetrySettings implements Serializable {
@@ -74,36 +80,61 @@ public abstract class RetrySettings implements Serializable {
7480

7581
/**
7682
* TotalTimeout has ultimate control over how long the logic should keep trying the remote call
77-
* until it gives up completely. The higher the total timeout, the more retries can be attempted.
78-
* The default value is {@code Duration.ZERO}.
83+
* until it gives up completely. The higher the total timeout, the more retries and polls can be
84+
* attempted. If this value is {@code Duration.ZERO}, then the logic will instead use the number
85+
* of attempts to determine retries. In the event that both maxAttempts and totalTimeout values
86+
* are both 0, the logic will not retry. If this value is non-{@code Duration.ZERO}, and the retry
87+
* duration has reaches the timeout value, the logic will give up retrying even the number of
88+
* attempts is lower than the maxAttempts value.
89+
*
90+
* <p>If there are no configurations, Retries have the default timeout value of {@code
91+
* Duration.ZERO} and LROs have a default total timeout value of {@code Duration.ofMillis(300000)}
92+
* (5 minutes).
7993
*/
8094
public abstract Duration getTotalTimeout();
8195

8296
/**
83-
* InitialRetryDelay controls the delay before the first retry. Subsequent retries will use this
84-
* value adjusted according to the RetryDelayMultiplier. The default value is {@code
85-
* Duration.ZERO}.
97+
* InitialRetryDelay controls the delay before the first retry/ poll. Subsequent retries and polls
98+
* will use this value adjusted according to the RetryDelayMultiplier.
99+
*
100+
* <p>If there are no configurations, Retries have the default initial retry delay value of {@code
101+
* Duration.ZERO} and LROs have a default initial poll delay value of {@code
102+
* Duration.ofMillis(5000)} (5 seconds).
86103
*/
87104
public abstract Duration getInitialRetryDelay();
88105

89106
/**
90-
* RetryDelayMultiplier controls the change in retry delay. The retry delay of the previous call
91-
* is multiplied by the RetryDelayMultiplier to calculate the retry delay for the next call. The
92-
* default value is {@code 1.0}.
107+
* RetryDelayMultiplier controls the change in delay before the next retry or poll. The retry
108+
* delay of the previous call is multiplied by the RetryDelayMultiplier to calculate the retry
109+
* delay for the next call.
110+
*
111+
* <p>If there are no configurations, Retries have the default retry delay multiplier value of
112+
* {@code 1.0} and LROs have a default retry delay multiplier of {@code 1.5}.
93113
*/
94114
public abstract double getRetryDelayMultiplier();
95115

96116
/**
97117
* MaxRetryDelay puts a limit on the value of the retry delay, so that the RetryDelayMultiplier
98-
* can't increase the retry delay higher than this amount. The default value is {@code
99-
* Duration.ZERO}.
118+
* can't increase the retry delay higher than this amount.
119+
*
120+
* <p>If there are no configurations, Retries have the default max retry delay value of {@code
121+
* Duration.ZERO} and LROs have a default max poll retry delay value of {@code
122+
* Duration.ofMillis(45000)} (45 seconds).
100123
*/
101124
public abstract Duration getMaxRetryDelay();
102125

103126
/**
104-
* MaxAttempts defines the maximum number of attempts to perform. The default value is {@code 0}.
105-
* If this value is greater than 0, and the number of attempts reaches this limit, the logic will
106-
* give up retrying even if the total retry time is still lower than TotalTimeout.
127+
* MaxAttempts defines the maximum number of retry attempts to perform. If this value is set to 0,
128+
* the logic will instead use the totalTimeout value to determine retries. In the event that both
129+
* the maxAttempts and totalTimeout values are both 0, the logic will not retry. If this value is
130+
* greater than 0, and the number of attempts exceeds this limit, the logic will give up retrying
131+
* even if the total retry time is still lower than totalTimeout.
132+
*
133+
* <p>If there are no configurations, Retries and LROs have the default max attempt value of
134+
* {@code 0}. LRO polling does not use this value by default.
135+
*
136+
* <p>The first RPC invocation will be considered attempt #0. Subsequent calls (retries) will
137+
* increment the number of attempts and the number of attempts will not exceed this value.
107138
*/
108139
public abstract int getMaxAttempts();
109140

@@ -123,22 +154,30 @@ public abstract class RetrySettings implements Serializable {
123154

124155
/**
125156
* InitialRpcTimeout controls the timeout for the initial RPC. Subsequent calls will use this
126-
* value adjusted according to the RpcTimeoutMultiplier. The default value is {@code
127-
* Duration.ZERO}.
157+
* value adjusted according to the RpcTimeoutMultiplier. RPC Timeout value of {@code
158+
* Duration.ZERO} allows the RPC to continue indefinitely (until it hits a Connect Timeout or the
159+
* connection has been terminated).
160+
*
161+
* <p>If there are no configurations, Retries have the default initial RPC timeout value of {@code
162+
* Duration.ZERO}. LRO polling does not use the Initial RPC Timeout value.
128163
*/
129164
public abstract Duration getInitialRpcTimeout();
130165

131166
/**
132167
* RpcTimeoutMultiplier controls the change in RPC timeout. The timeout of the previous call is
133-
* multiplied by the RpcTimeoutMultiplier to calculate the timeout for the next call. The default
134-
* value is {@code 1.0}.
168+
* multiplied by the RpcTimeoutMultiplier to calculate the timeout for the next call.
169+
*
170+
* <p>If there are no configurations, Retries have the default RPC Timeout Multiplier value of
171+
* {@code 1.0}. LRO polling does not use the RPC Timeout Multiplier value.
135172
*/
136173
public abstract double getRpcTimeoutMultiplier();
137174

138175
/**
139176
* MaxRpcTimeout puts a limit on the value of the RPC timeout, so that the RpcTimeoutMultiplier
140-
* can't increase the RPC timeout higher than this amount. The default value is {@code
141-
* Duration.ZERO}.
177+
* can't increase the RPC timeout higher than this amount.
178+
*
179+
* <p>If there are no configurations, Retries have the default Max RPC Timeout value of {@code
180+
* Duration.ZERO}. LRO polling does not use the Max RPC Timeout value.
142181
*/
143182
public abstract Duration getMaxRpcTimeout();
144183

@@ -166,36 +205,61 @@ public abstract static class Builder {
166205

167206
/**
168207
* TotalTimeout has ultimate control over how long the logic should keep trying the remote call
169-
* until it gives up completely. The higher the total timeout, the more retries can be
170-
* attempted. The default value is {@code Duration.ZERO}.
208+
* until it gives up completely. The higher the total timeout, the more retries and polls can be
209+
* attempted. If this value is {@code Duration.ZERO}, then the logic will instead use the number
210+
* of attempts to determine retries. In the event that both maxAttempts and totalTimeout values
211+
* are both 0, the logic will not retry. If this value is non-{@code Duration.ZERO}, and the
212+
* retry duration has reaches the timeout value, the logic will give up retrying even the number
213+
* of attempts is lower than the maxAttempts value.
214+
*
215+
* <p>If there are no configurations, Retries have the default timeout value of {@code
216+
* Duration.ZERO} and LROs have a default total timeout value of {@code
217+
* Duration.ofMillis(300000)} (5 minutes).
171218
*/
172219
public abstract Builder setTotalTimeout(Duration totalTimeout);
173220

174221
/**
175-
* InitialRetryDelay controls the delay before the first retry. Subsequent retries will use this
176-
* value adjusted according to the RetryDelayMultiplier. The default value is {@code
177-
* Duration.ZERO}.
222+
* InitialRetryDelay controls the delay before the first retry/ poll. Subsequent retries and
223+
* polls will use this value adjusted according to the RetryDelayMultiplier.
224+
*
225+
* <p>If there are no configurations, Retries have the default initial retry delay value of
226+
* {@code Duration.ZERO} and LROs have a default initial poll delay value of {@code
227+
* Duration.ofMillis(5000)} (5 seconds).
178228
*/
179229
public abstract Builder setInitialRetryDelay(Duration initialDelay);
180230

181231
/**
182-
* RetryDelayMultiplier controls the change in retry delay. The retry delay of the previous call
183-
* is multiplied by the RetryDelayMultiplier to calculate the retry delay for the next call. The
184-
* default value is {@code 1.0}.
232+
* RetryDelayMultiplier controls the change in delay before the next retry or poll. The retry
233+
* delay of the previous call is multiplied by the RetryDelayMultiplier to calculate the retry
234+
* delay for the next call.
235+
*
236+
* <p>If there are no configurations, Retries have the default retry delay multiplier value of
237+
* {@code 1.0} and LROs have a default retry delay multiplier of {@code 1.5}.
185238
*/
186239
public abstract Builder setRetryDelayMultiplier(double multiplier);
187240

188241
/**
189242
* MaxRetryDelay puts a limit on the value of the retry delay, so that the RetryDelayMultiplier
190-
* can't increase the retry delay higher than this amount. The default value is {@code
191-
* Duration.ZERO}.
243+
* can't increase the retry delay higher than this amount.
244+
*
245+
* <p>If there are no configurations, Retries have the default max retry delay value of {@code
246+
* Duration.ZERO} and LROs have a default max poll retry delay value of {@code
247+
* Duration.ofMillis(45000)} (45 seconds).
192248
*/
193249
public abstract Builder setMaxRetryDelay(Duration maxDelay);
194250

195251
/**
196-
* MaxAttempts defines the maximum number of attempts to perform. The default value is {@code
197-
* 0}. If this value is greater than 0, and the number of attempts reaches this limit, the logic
198-
* will give up retrying even if the total retry time is still lower than TotalTimeout.
252+
* MaxAttempts defines the maximum number of retry attempts to perform. If this value is set to
253+
* 0, the logic will instead use the totalTimeout value to determine retries. In the event that
254+
* both the maxAttempts and totalTimeout values are both 0, the logic will not retry. If this
255+
* value is greater than 0, and the number of attempts exceeds this limit, the logic will give
256+
* up retrying even if the total retry time is still lower than totalTimeout.
257+
*
258+
* <p>If there are no configurations, Retries and LROs have the default max attempt value of
259+
* {@code 0}. LRO polling does not use this value by default.
260+
*
261+
* <p>The first RPC invocation will be considered attempt #0. Subsequent calls (retries) will
262+
* increment the number of attempts and the number of attempts will not exceed this value.
199263
*/
200264
public abstract Builder setMaxAttempts(int maxAttempts);
201265

@@ -215,49 +279,80 @@ public abstract static class Builder {
215279

216280
/**
217281
* InitialRpcTimeout controls the timeout for the initial RPC. Subsequent calls will use this
218-
* value adjusted according to the RpcTimeoutMultiplier. The default value is {@code
219-
* Duration.ZERO}.
282+
* value adjusted according to the RpcTimeoutMultiplier. RPC Timeout value of {@code
283+
* Duration.ZERO} allows the RPC to continue indefinitely (until it hits a Connect Timeout or
284+
* the connection has been terminated).
285+
*
286+
* <p>If there are no configurations, Retries have the default initial RPC timeout value of
287+
* {@code Duration.ZERO}. LRO polling does not use the Initial RPC Timeout value.
220288
*/
221289
public abstract Builder setInitialRpcTimeout(Duration initialTimeout);
222290

223291
/**
224-
* See the class documentation of {@link RetrySettings} for a description of what this value
225-
* does. The default value is {@code 1.0}.
292+
* RpcTimeoutMultiplier controls the change in RPC timeout. The timeout of the previous call is
293+
* multiplied by the RpcTimeoutMultiplier to calculate the timeout for the next call.
294+
*
295+
* <p>If there are no configurations, Retries have the default RPC Timeout Multiplier value of
296+
* {@code 1.0}. LRO polling does not use the RPC Timeout Multiplier value.
226297
*/
227298
public abstract Builder setRpcTimeoutMultiplier(double multiplier);
228299

229300
/**
230301
* MaxRpcTimeout puts a limit on the value of the RPC timeout, so that the RpcTimeoutMultiplier
231-
* can't increase the RPC timeout higher than this amount. The default value is {@code
232-
* Duration.ZERO}.
302+
* can't increase the RPC timeout higher than this amount.
303+
*
304+
* <p>If there are no configurations, Retries have the default Max RPC Timeout value of {@code
305+
* Duration.ZERO}. LRO polling does not use the Max RPC Timeout value.
233306
*/
234307
public abstract Builder setMaxRpcTimeout(Duration maxTimeout);
235308

236309
/**
237310
* TotalTimeout has ultimate control over how long the logic should keep trying the remote call
238-
* until it gives up completely. The higher the total timeout, the more retries can be
239-
* attempted. The default value is {@code Duration.ZERO}.
311+
* until it gives up completely. The higher the total timeout, the more retries and polls can be
312+
* attempted. If this value is {@code Duration.ZERO}, then the logic will instead use the number
313+
* of attempts to determine retries. In the event that both maxAttempts and totalTimeout values
314+
* are both 0, the logic will not retry. If this value is non-{@code Duration.ZERO}, and the
315+
* retry duration has reaches the timeout value, the logic will give up retrying even the number
316+
* of attempts is lower than the maxAttempts value.
317+
*
318+
* <p>If there are no configurations, Retries have the default timeout value of {@code
319+
* Duration.ZERO} and LROs have a default total timeout value of {@code
320+
* Duration.ofMillis(300000)} (5 minutes).
240321
*/
241322
public abstract Duration getTotalTimeout();
242323

243324
/**
244-
* InitialRetryDelay controls the delay before the first retry. Subsequent retries will use this
245-
* value adjusted according to the RetryDelayMultiplier. The default value is {@code
246-
* Duration.ZERO}.
325+
* InitialRetryDelay controls the delay before the first retry/ poll. Subsequent retries and
326+
* polls will use this value adjusted according to the RetryDelayMultiplier.
327+
*
328+
* <p>If there are no configurations, Retries have the default initial retry delay value of
329+
* {@code Duration.ZERO} and LROs have a default initial poll delay value of {@code
330+
* Duration.ofMillis(5000)} (5 seconds).
247331
*/
248332
public abstract Duration getInitialRetryDelay();
249333

250334
/**
251-
* RetryDelayMultiplier controls the change in retry delay. The retry delay of the previous call
252-
* is multiplied by the RetryDelayMultiplier to calculate the retry delay for the next call. The
253-
* default value is {@code 1.0}.
335+
* RetryDelayMultiplier controls the change in delay before the next retry or poll. The retry
336+
* delay of the previous call is multiplied by the RetryDelayMultiplier to calculate the retry
337+
* delay for the next call.
338+
*
339+
* <p>If there are no configurations, Retries have the default retry delay multiplier value of
340+
* {@code 1.0} and LROs have a default retry delay multiplier of {@code 1.5}.
254341
*/
255342
public abstract double getRetryDelayMultiplier();
256343

257344
/**
258-
* MaxAttempts defines the maximum number of attempts to perform. The default value is {@code
259-
* 0}. If this value is greater than 0, and the number of attempts reaches this limit, the logic
260-
* will give up retrying even if the total retry time is still lower than TotalTimeout.
345+
* MaxAttempts defines the maximum number of retry attempts to perform. If this value is set to
346+
* 0, the logic will instead use the totalTimeout value to determine retries. In the event that
347+
* both the maxAttempts and totalTimeout values are both 0, the logic will not retry. If this
348+
* value is greater than 0, and the number of attempts exceeds this limit, the logic will give
349+
* up retrying even if the total retry time is still lower than totalTimeout.
350+
*
351+
* <p>If there are no configurations, Retries and LROs have the default max attempt value of
352+
* {@code 0}. LRO polling does not use this value by default.
353+
*
354+
* <p>The first RPC invocation will be considered attempt #0. Subsequent calls (retries) will
355+
* increment the number of attempts and the number of attempts will not exceed this value.
261356
*/
262357
public abstract int getMaxAttempts();
263358

@@ -273,27 +368,40 @@ public abstract static class Builder {
273368

274369
/**
275370
* MaxRetryDelay puts a limit on the value of the retry delay, so that the RetryDelayMultiplier
276-
* can't increase the retry delay higher than this amount. The default value is {@code
277-
* Duration.ZERO}.
371+
* can't increase the retry delay higher than this amount.
372+
*
373+
* <p>If there are no configurations, Retries have the default max retry delay value of {@code
374+
* Duration.ZERO} and LROs have a default max poll retry delay value of {@code
375+
* Duration.ofMillis(45000)} (45 seconds).
278376
*/
279377
public abstract Duration getMaxRetryDelay();
280378

281379
/**
282380
* InitialRpcTimeout controls the timeout for the initial RPC. Subsequent calls will use this
283-
* value adjusted according to the RpcTimeoutMultiplier. The default value is {@code
284-
* Duration.ZERO}.
381+
* value adjusted according to the RpcTimeoutMultiplier. RPC Timeout value of {@code
382+
* Duration.ZERO} allows the RPC to continue indefinitely (until it hits a Connect Timeout or
383+
* the connection has been terminated).
384+
*
385+
* <p>If there are no configurations, Retries have the default initial RPC timeout value of
386+
* {@code Duration.ZERO}. LRO polling does not use the Initial RPC Timeout value.
285387
*/
286388
public abstract Duration getInitialRpcTimeout();
287389

288390
/**
289-
* See the class documentation of {@link RetrySettings} for a description of what this value
290-
* does. The default value is {@code 1.0}.
391+
* RpcTimeoutMultiplier controls the change in RPC timeout. The timeout of the previous call is
392+
* multiplied by the RpcTimeoutMultiplier to calculate the timeout for the next call.
393+
*
394+
* <p>If there are no configurations, Retries have the default RPC Timeout Multiplier value of
395+
* {@code 1.0}. LRO polling does not use the RPC Timeout Multiplier value.
291396
*/
292397
public abstract double getRpcTimeoutMultiplier();
293398

294399
/**
295400
* MaxRpcTimeout puts a limit on the value of the RPC timeout, so that the RpcTimeoutMultiplier
296401
* can't increase the RPC timeout higher than this amount.
402+
*
403+
* <p>If there are no configurations, Retries have the default Max RPC Timeout value of {@code
404+
* Duration.ZERO}. LRO polling does not use the Max RPC Timeout value.
297405
*/
298406
public abstract Duration getMaxRpcTimeout();
299407

0 commit comments

Comments
 (0)