2012-01-23 17:05:03 -05:00
|
|
|
require 'active_support/inflector'
|
|
|
|
|
2012-01-16 23:05:38 -05:00
|
|
|
module Sidekiq
|
|
|
|
class Worker
|
|
|
|
include Celluloid
|
|
|
|
|
2012-01-24 01:08:38 -05:00
|
|
|
def initialize(boss)
|
|
|
|
@boss = boss
|
|
|
|
end
|
|
|
|
|
2012-01-22 14:32:38 -05:00
|
|
|
def process(msg)
|
2012-01-21 19:42:21 -05:00
|
|
|
begin
|
2012-01-22 14:32:38 -05:00
|
|
|
klass = msg['class'].constantize
|
|
|
|
klass.new.perform(*msg['args'])
|
2012-01-24 01:08:38 -05:00
|
|
|
@boss.worker_done!(current_actor)
|
2012-01-21 19:42:21 -05:00
|
|
|
rescue => ex
|
2012-01-22 14:32:38 -05:00
|
|
|
send_to_airbrake(msg, ex) if defined?(::Airbrake)
|
2012-01-21 19:42:21 -05:00
|
|
|
raise ex
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-22 14:32:38 -05:00
|
|
|
def send_to_airbrake(msg, ex)
|
2012-01-21 19:42:21 -05:00
|
|
|
::Airbrake.notify(:error_class => ex.class.name,
|
|
|
|
:error_message => "#{ex.class.name}: #{e.message}",
|
|
|
|
:parameters => json)
|
2012-01-16 23:05:38 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|