Skip to content

Commit

Permalink
fix: editing retry logic (#1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
alicejli committed Sep 15, 2021
1 parent 5bdb180 commit 05548d5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/gax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,32 @@ export class CallSettings {
let longrunning = this.longrunning;
let apiName = this.apiName;
let retryRequestOptions = this.retryRequestOptions;
// If a method-specific timeout is set in the service config, and the retry codes for that
// method are non-null, then that timeout value will be used to
// override backoff settings.
if (
retry !== undefined &&
retry !== null &&
retry.retryCodes !== null &&
retry.retryCodes.length > 0
) {
retry.backoffSettings.initialRpcTimeoutMillis = timeout;
retry.backoffSettings.maxRpcTimeoutMillis = timeout;
retry.backoffSettings.totalTimeoutMillis = timeout;
}
// If the user provides a timeout to the method, that timeout value will be used
// to override the backoff settings.
if ('timeout' in options) {
timeout = options.timeout!;
if (
retry !== undefined &&
retry !== null &&
retry.retryCodes.length > 0
) {
retry.backoffSettings.initialRpcTimeoutMillis = timeout;
retry.backoffSettings.maxRpcTimeoutMillis = timeout;
retry.backoffSettings.totalTimeoutMillis = timeout;
}
}
if ('retry' in options) {
retry = mergeRetryOptions(retry || ({} as RetryOptions), options.retry!);
Expand Down

0 comments on commit 05548d5

Please sign in to comment.