-
Notifications
You must be signed in to change notification settings - Fork 370
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
feat: customize retry behavior implementation #1474
Conversation
…is/nodejs-storage into shaffeeullah/retryConfiguration
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. |
There was a problem hiding this comment.
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
@@ -46,6 +46,9 @@ export interface CreateBucketQuery { | |||
} | |||
|
|||
export interface StorageOptions extends ServiceOptions { | |||
backoffMultiplier?: number; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
…dejs-storage into shaffeeullah/retryConfiguration
…is/nodejs-storage into shaffeeullah/retryConfiguration
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; |
There was a problem hiding this comment.
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
Line 381 in fbb90c2
const RESUMABLE_THRESHOLD = 5000000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed! good callout
…is/nodejs-storage into shaffeeullah/retryConfiguration
test/index.ts
Outdated
it('should throw if autoRetry is defined twice', () => { | ||
const autoRetry = 10; | ||
assert.throws(() => { | ||
const storage = new Storage({ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* 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]>
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.autoRetry
andmaxRetries
implementation currently relies onnodejs-common
defaults. This PR also pulls control over these defaults into thenodejs-storage
library.