ShopifySharp 6.16.0
Summary
This release introduces a new request execution policy for ShopifySharp called ExponentialRetryPolicy
! As the name suggests, this policy is responsible for making requests to Shopify's API, and then introducing an exponential delay between the last failure and the next time it tries to send the request. The exponential delay is on a per-request basis, so there's no attempt to be "smart" in this policy or to perform any sort of lookup on the access token being used or the leaky bucket status.
You can configure the new policy using the ExponentialRetryPolicyOptions
class:
var policyOptions = new ExponentialRetryPolicyOptions
{
InitialBackoffInMillseconds = 50,
MaximumDelayBetweenRetries = TimeSpan.FromSeconds(1),
MaximumTriesBeforeRequestCancellation = null,
MaximumDelayBeforeRequestCancellation = TimeSpan.FromSeconds(5)
};
Note that MaximumTriesBeforeRequestCancellation
and MaximumDelayBeforeRequestCancellation
are both nullalbe, but one of them is in fact required and will be validated when the policy is constructed.
Alongside the new policy, this release also adds the RequestResult.StatusCode
property, which should make it a simple matter to grab the response's status code in custom IRequestExecutionPolicy
"middleware" without relying on the deprecated (and soon to be removed) HttpPRequestMessage
object.
Finally, there's a small change that most won't noticed in this pull request unless you've got your own custom IRequestExecutionPolicy
. The return result types of RequestResult.GetRestBucketState
and RequestResult.GetGraphQLBucketState
were changed to be nullable. This does not actually change the underlying implementation – the methods could always return null, the types were simply updated to reflect that fact.
Changelog
- Add RequestResult.StatusCode property by @nozzlegear in #1063
- Make RequestResult bucket state return types nullable, plus misc refactoring by @nozzlegear in #1066
- Feature: Retry policy with exponential delay by @nozzlegear in #1065
Full Changelog: ShopifySharp/6.15.1...ShopifySharp/6.16.0
How to support ShopifySharp
If you find ShopifySharp useful, please consider contributing to the project! If you'd rather contribute financially, you can do so by sponsoring the author here on Github, or by purchasing a copy of The Shopify Development Handbook on Gumroad.