Class: Sqskiq::Processor

Inherits:
Object
  • Object
show all
Includes:
Celluloid, SignalHandler
Defined in:
lib/sqskiq/process.rb

Instance Method Summary collapse

Methods included from SignalHandler

#shutting_down, #subscribe_for_shutdown

Constructor Details

#initialize(worker_class) ⇒ Processor

Returns a new instance of Processor.



10
11
12
13
# File 'lib/sqskiq/process.rb', line 10

def initialize(worker_class)
  @worker_instance = worker_class.new
  subscribe_for_shutdown
end

Instance Method Details

#process(message) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sqskiq/process.rb', line 15

def process(message)
  return  { :success => false, :message => message } if @shutting_down

  result = true
  begin
    @worker_instance.perform(message)
  rescue Exception => e
    result = false
  end
  return { :success => result, :message => message }
end