Beispiel #1
0
        public void SetRESTBucketState(int maximumAvailable, double currentlyAvailable)
        {
            //Shopify Plus customers have a bucket that is twice the size (80) so we resize the bucket capacity accordingly
            //It is apparently possible to request the bucket size to be even larger
            //https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/what-is-the-default-api-call-limit-on-shopify-stores-407292
            //Note that when the capacity doubles, the leak rate also doubles. So, not only can request bursts be larger, it is also possible to sustain a faster rate over the long term.
            int restoreRatePerSecond = maximumAvailable / DEFAULT_REST_MAX_AVAILABLE * DEFAULT_REST_RESTORE_RATE;

            //Shopify might not have yet 'seen' requests in flight that were issued during the current request
            //i.e. multiple requests can receive their response out of order, causing the latest response bucket information to be incorrect (it is stale)
            currentlyAvailable = Math.Min(RESTBucket.ComputedCurrentlyAvailable, currentlyAvailable);

            RESTBucket.SetState(maximumAvailable, restoreRatePerSecond, currentlyAvailable);
        }
Beispiel #2
0
 public async Task WaitForAvailableRESTAsync(CancellationToken cancellationToken)
 {
     //REST calls all count for the same cost of 1
     await RESTBucket.WaitForAvailableAsync(1, cancellationToken);
 }