Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: customize retry behavior implementation #1474

Merged

Conversation

shaffeeullah
Copy link
Contributor

Custom retry strategy behavior on the storage side. Will merge all storage retry PRs into the shaffeeullah/retryStrategy branch and then merge that branch into master at the end. This avoids one giant PR.

  • Note: autoRetry and maxRetries implementation currently relies on nodejs-common defaults. This PR also pulls control over these defaults into the nodejs-storage library.

@shaffeeullah shaffeeullah requested a review from a team May 27, 2021 15:10
@shaffeeullah shaffeeullah requested a review from a team as a code owner May 27, 2021 15:10
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label May 27, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label May 27, 2021
src/storage.ts Outdated
@@ -371,6 +374,13 @@ export class Storage extends Service {
* @property {boolean} [autoRetry=true] Automatically retry requests if the
* response is related to rate limits or certain intermittent server
* errors. We will exponentially backoff subsequent requests by default.
* @property {number} [backoffMultiplier = 2] Dictates the rate of exponential backoff.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be clearer if you add a little explanation/example about how these parameters interact with one another. For example with the default settings, up to how many retries will happen and how much will they be spaced out? You could also link to something explaining backoff if that's easier.

src/storage.ts Outdated Show resolved Hide resolved
src/storage.ts Outdated
@@ -46,6 +46,9 @@ export interface CreateBucketQuery {
}

export interface StorageOptions extends ServiceOptions {
backoffMultiplier?: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we considered factoring the retry options into some sort of sub-config? Not sure if this is a thing in Node. In Go for example the various mathy configs are all in https://pkg.go.dev/github.com/googleapis/gax-go/v2#Backoff

src/storage.ts Outdated
@@ -393,6 +405,12 @@ export class Storage extends Service {
* @param {StorageOptions} [options] Configuration options.
*/
constructor(options: StorageOptions = {}) {
const AUTO_RETRY_DEFAULT = true;
const MAX_RETRY_DEFAULT = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this constant being used already? 3 seems way too low.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is the current default

src/storage.ts Outdated
@@ -393,6 +420,12 @@ export class Storage extends Service {
* @param {StorageOptions} [options] Configuration options.
*/
constructor(options: StorageOptions = {}) {
const AUTO_RETRY_DEFAULT = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to move these constants to the class level along with a comment for consistency with other files? For example

const RESUMABLE_THRESHOLD = 5000000;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed! good callout

test/index.ts Outdated
it('should throw if autoRetry is defined twice', () => {
const autoRetry = 10;
assert.throws(() => {
const storage = new Storage({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is testing that the constructor throws an exception could the assignment to the const be removed to cleanup the linter warning? Same goes for L285.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, totally missed the linter warnings. fixed

…is/nodejs-storage into shaffeeullah/retryConfiguration
Copy link
Contributor

@ddelgrosso1 ddelgrosso1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shaffeeullah shaffeeullah merged commit cb0d9ac into shaffeeullah/retryStrategy Jun 16, 2021
@shaffeeullah shaffeeullah deleted the shaffeeullah/retryConfiguration branch June 16, 2021 19:25
shaffeeullah added a commit that referenced this pull request Jul 21, 2021
* feat: customize retry behavior implementation (#1474)

* feat: customize retry behavior implementation

* 🦉 Updates from OwlBot

* fixed !=

* 🦉 Updates from OwlBot

* updated names to match gogle gax

* 🦉 Updates from OwlBot

* refactored retryOptions into its own config

* 🦉 Updates from OwlBot

* fixed linting error

* 🦉 Updates from OwlBot

* added retry delay explanation

* 🦉 Updates from OwlBot

* refactored constants

* 🦉 Updates from OwlBot

* removed const assignment

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>

* feat: implemented retry function (#1476)

* implemented retry function

* 🦉 Updates from OwlBot

* fixed import

* 🦉 Updates from OwlBot

* resolved merge conflict

* passed retry function to common

* 🦉 Updates from OwlBot

* refactored code to retryableErrFn

* removed unused import

* fixed typo

* fixed typo

* fixed failing tests

* made retryableErrorFn configurable

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md

* wrote unit tests

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md

* changed reason check to be less brittle

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>

* depend on common 3.7.0 for retry changes

* feat: remove gaxios dependency (#1503)

* feat: remove gaxios dependency

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md

* moved callbackFunction inline

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md

* assigned types to any

* changed any to string

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>

* feat: applied customization to multipart filesave (#1504)

* feat: applied customization to multipart filesave

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md

* fixed failing tests

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md

* removed unused import

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>

* Update storage.ts

added comment next to EAI_AGAIN

* feat: pass retryOptions to gcs-resumable-upload (#1506)

* feat: pass retryOptions to gcs-resumable-upload

* linter fixes

* additional test assertions for retryOptions

* add additional asserts to resumable operation tests

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Denis DelGrosso <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants