-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default number of network retries to 2 (#1069)
Currently, it's possible to have the library retry intermittently failed requests by configuring `MaxNetworkRetries` on a `BackendConfig`. 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` is currently a simple `int`, which means that it's hard for us to recognize an 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: ``` go if conf.MaxNetworkRetries == 0 { backend.MaxNetworkRetries = 2 } ``` The most obvious solution is that change `MaxNetworkRetries` to a nilable 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: ``` patch config := &stripe.BackendConfig{ - MaxNetworkRetries: 2, + MaxNetworkRetries: stripe.Int64(2), } ``` 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 from `bool` to `*bool` and `URL` changes from `string` to `*string`. I don't think this is a big deal because ~99% of users will probably just be using the defaults by having left them unset.
- Loading branch information
Showing
7 changed files
with
77 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters