2012-01-26 15:45:04 -05:00
|
|
|
require 'sidekiq/util'
|
|
|
|
require 'celluloid'
|
2012-01-25 16:32:51 -05:00
|
|
|
|
|
|
|
module Sidekiq
|
|
|
|
class Processor
|
2012-01-26 15:45:04 -05:00
|
|
|
include Util
|
|
|
|
include Celluloid unless $TESTING
|
2012-01-25 16:32:51 -05:00
|
|
|
|
|
|
|
def initialize(boss)
|
|
|
|
@boss = boss
|
|
|
|
end
|
|
|
|
|
|
|
|
def process(msg)
|
|
|
|
begin
|
2012-01-26 15:45:04 -05:00
|
|
|
klass = constantize(msg['class'])
|
2012-01-25 16:32:51 -05:00
|
|
|
klass.new.perform(*msg['args'])
|
2012-01-26 16:02:47 -05:00
|
|
|
@boss.processor_done!(current_actor)
|
2012-01-25 16:32:51 -05:00
|
|
|
rescue => ex
|
|
|
|
send_to_airbrake(msg, ex) if defined?(::Airbrake)
|
|
|
|
raise ex
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def send_to_airbrake(msg, ex)
|
|
|
|
::Airbrake.notify(:error_class => ex.class.name,
|
2012-01-26 15:45:04 -05:00
|
|
|
:error_message => "#{ex.class.name}: #{ex.message}",
|
|
|
|
:parameters => msg)
|
2012-01-25 16:32:51 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|