mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
2771a0ad96
Workers are the user's classes, the threads are now called processors. Add secret sauce to make Rails config much easier. Use a railtie to auto-add app/workers to the autoload path.
28 lines
650 B
Ruby
28 lines
650 B
Ruby
require 'active_support/inflector'
|
|
|
|
module Sidekiq
|
|
class Processor
|
|
include Celluloid
|
|
|
|
def initialize(boss)
|
|
@boss = boss
|
|
end
|
|
|
|
def process(msg)
|
|
begin
|
|
klass = msg['class'].constantize
|
|
klass.new.perform(*msg['args'])
|
|
@boss.processor_done!(current_actor)
|
|
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,
|
|
:error_message => "#{ex.class.name}: #{e.message}",
|
|
:parameters => json)
|
|
end
|
|
end
|
|
end
|