Skip to content

Conversation

@hiranya911
Copy link
Contributor

  • Increased retry count to 4
  • Backoff factor set to 0.5 (this results in the delay pattern of 0s, 1s, 2s and 4s)

const scope = nock('https://' + mockHost)
.get(mockPath)
.twice()
.times(5)
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 is better to test passing explicit RetryConfig instead so you don't have to do things like:
(client as any).retry.backOffFactor = 0;

This also makes it easier to add changes to default config in the future.

And then add a test for default config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@bojeil-google bojeil-google left a comment

Choose a reason for hiding this comment

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

Just a few minor suggestions.

maxDelayInMillis: 1000,
statusCodes: [503],
});
const client = new HttpClient();
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this use testRetryConfig() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

maxDelayInMillis: 60 * 1000,
statusCodes: [503],
});
const client = new HttpClient();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should you pass explicit test retry config with backoff factor on, here and elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used defaultRetryConfig() directly.

*
* @return {RetryConfig} A new RetryConfig instance.
*/
function testRetryConfig(): RetryConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this take a parameter whether to reset backOffFactor and then you can use it in all tests not testing default behavior but require backOffFactor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's same as default config. So using defaultRetryConfig() directly.

@hiranya911
Copy link
Contributor Author

@bojeil-google I used defaultRetryConfig() explicitly in the tests you pointed out to make the intention clear. Please take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants