Sha256: 1ce6e8c09b9a8514d8d9e96e60779aaff2dae57b5c47e8886b9ac86958049f59
Contents?: true
Size: 715 Bytes
Versions: 2
Compression:
Stored size: 715 Bytes
Contents
require 'iron_mq' class Fanforce::Workers def initialize(opts={}) @opts = opts end def iron require_relative 'iron' @iron ||= Fanforce::Workers::Iron.new(@opts) end def self.enqueue(queue_id, payload) self.new.enqueue(queue_id, payload) end def enqueue(queue_id, payload) raise 'Payload being sent to the queue must be a Hash' if !payload.is_a?(Hash) iron.enqueue queue_id, params: payload, retries: 0 end def retry_error(queue_id, msg_id) msg = iron.client.queue(queue_id + '-ERRORS').peek(msg_id) data = MultiJson.load(msg.body, :symbolize_keys => true) iron.enqueue queue_id, params: data[:params], retries: data[:retries] + 1 msg.delete end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fanforce-workers-0.4.5 | lib/fanforce/workers/workers.rb |
fanforce-workers-0.4.4 | lib/fanforce/workers/workers.rb |