Default number of network retries to 2 #1069
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, it's possible to have the library retry intermittently failed
requests by configuring
MaxNetworkRetries
on aBackendConfig
.Because this is a pretty useful feature that many users will never
discover because it's off by default, we've been mulling around the idea
internally to change that default on the next major so that more people
get access to it. We're about to release V71, so now is an opportune
moment.
The slight complication is that
BackendConfig.MaxNetworkRetries
iscurrently a simple
int
, which means that it's hard for us to recognizean unset value versus an explicitly set 0 (the same problem we had with
fields on parameter structs for years). So by example, this code is
problematic:
The most obvious solution is that change
MaxNetworkRetries
to anilable pointer, and have it set using our
stripe.Int64
helper,exactly as we do for parameter structs. So compared to today,
configuring it would change like this:
It's not too bad, and follows convention found elsewhere in the library,
but will require a small code update for users.
The slight follow on complication is that to make
BackendConfig
self-consistent, I also changed the other primitives on it to also be
pointers, so
EnableTelemetry
changes frombool
to*bool
andURL
changes from
string
to*string
. I don't think this is a big dealbecause ~99% of users will probably just be using the defaults by having
left them unset.
r? @ob-stripe @remi-stripe A little more complicated than I was
originally hoping, but not too bad. I still think we should do it.
Thoughts?
cc @stripe/api-libraries
Note: Targets the branch in #1055 for V71 integration.