Sha256: bf92dd8b925fc1b7a665fdd06b73041f2848a47acb69daebb3fb5c0c07ba00ae
Contents?: true
Size: 1.26 KB
Versions: 8
Compression:
Stored size: 1.26 KB
Contents
class Fanforce::Worker LOADED_AT = Time.now @@iron = {} @@redis = {} @@log = Logger.new($stdout) def self.iron_token @@iron[:token] || ENV['IRON_TOKEN'] end def self.iron_project_id @@iron[:project_id] || ENV['IRON_PROJECT_ID'] end def self.iron_mq require 'iron_mq' @@iron[:mq] ||= IronMQ::Client.new(:token => @@iron[:token], :project_id => @@iron[:project_id]) end def self.redis_url @@redis[:url] || ENV['REDIS_URL_ERRORLOG'] end def self.set_config(obj) @@iron[:token] = obj[:iron_token] if obj[:iron_token] @@iron[:project_id] = obj[:iron_project_id] if obj[:iron_project_id] @@redis[:url] = obj[:redis_url] if obj[:redis_url] end def self.log @@log end ########################################################################################## def self.enqueue(queue_id, params, options={}) raise 'Params being sent to the queue must be a Hash' if !params.is_a?(Hash) retries = (options[:retries].present?) ? options.delete(:retries) : 0 iron_mq.queue(queue_id).post({params: params, retries: retries}.to_json, options) end def self.run(worker_data, min_execution_time=300, &code_block) require_relative 'runner' Runner.new(worker_data, min_execution_time, &code_block) end end
Version data entries
8 entries across 8 versions & 1 rubygems