Sha256: e04266218d6e498d3adecf209044f026f4f250c0af3fa6538922e7d1c7200390
Contents?: true
Size: 938 Bytes
Versions: 3
Compression:
Stored size: 938 Bytes
Contents
require 'httparty' require 'celluloid' require 'filepath' module Quickdraw class ShopifyConnectorPool include HTTParty include Celluloid def initialize @config = Quickdraw.config @auth = {:username => @config[:api_key], :password => @config[:password]} end def request(call_type, path, options) options.merge!({:basic_auth => @auth}) begin tries ||= 3 response = HTTParty.send(call_type, path, options) if response.code == 429 tries += 1 puts "Too fast for Shopify! Retrying..." raise "Slow down!" end if response.code == 403 tries == 0 raise "Forbidden" end if response.code != 200 puts response.inspect raise "Request Failed" end rescue => e tries -= 1 if tries > 0 sleep 1 retry end end return response end end Celluloid::Actor[:shopify_connector_pool] = ShopifyConnectorPool.pool(:size => 24) end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
quickdraw-0.0.5 | lib/quickdraw/shopify_connector_pool.rb |
quickdraw-0.0.4 | lib/quickdraw/shopify_connector_pool.rb |
quickdraw-0.0.3 | lib/quickdraw/shopify_connector_pool.rb |