This is a gem for dealing with the API limits placed on the Shopify API.
Currently Shopify a leaky bucket limiter when using the API, if you go over that limit it will throw an exception.
By wrapping all the calls in a throttling method it is possible to wait until the API limit is reset or retry failing calls.
gem "shopify_api" gem "shopify-api-throttle"
Background workers will want to ensure that all of their calls are completed, even if that results in some delays in processing. To handle this a new method has been added that executes a block.
ShopifyAPI.throttle { shopifyObject.save! }
Remember scoping issues also apply:
collection = nil ShopifyAPI.throttle { collection = ShopifyAPI::CustomCollection.find(123) }
Or much easier
collection = ShopifyAPI.throttle { ShopifyAPI::CustomCollection.find(123) }
The block will be retried up to a number times, and will sleep for an increasing number of seconds between retries.