Sha256: 3efb001f58d92a3b5c6a681e7cedbfbf913f445131f9f5196d141696eb199a0d

Contents?: true

Size: 632 Bytes

Versions: 1

Compression:

Stored size: 632 Bytes

Contents

require 'httparty'
require 'celluloid'

module Quickdraw
	class ShopifyConnectorPool
		include HTTParty
		include Celluloid

		def get(path, options = {})

			begin
				tries ||= 3

				response = HTTParty.get(path, options)

				if response.code == 429
					tries += 1
					puts "Too fast for Shopify! Retrying..."
					raise "Slow down!"
				end

				if response.code != 200
					puts response.inspect
					raise "Request Failed"
				end

			rescue => e
				sleep 1
				retry unless (tries -= 1).zero?
			end

			return response
		end

	end

	Celluloid::Actor[:shopify_connector_pool] = ShopifyConnectorPool.pool(:size => 16)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quickdraw-0.0.2 lib/quickdraw/shopify_connector_pool.rb