1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/lib/sidekiq/worker.rb

24 lines
549 B
Ruby
Raw Normal View History

require 'active_support/inflector'
2012-01-16 23:05:38 -05:00
module Sidekiq
class Worker
include Celluloid
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-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