Module: Qwirk::ReplyWorker

Includes:
Worker
Defined in:
lib/qwirk/reply_worker.rb

Overview

Base Worker Class for any class that will be processing requests from queues and replying

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary

Attributes included from Worker

#impl, #message, #start_processing_time, #start_read_time, #start_worker_time, #status, #thread

Attributes included from BaseWorker

#config, #index

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Worker

#event_loop, #fail_queue_name, #init, #join, #log_backtrace, #on_message, #start, #stop, #to_s

Methods included from BaseWorker

#status, #stop, #to_s, worker_classes

Class Method Details

.included(base) ⇒ Object



19
20
21
22
# File 'lib/qwirk/reply_worker.rb', line 19

def self.included(base)
  Worker.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#perform(object) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/qwirk/reply_worker.rb', line 24

def perform(object)
  begin
    response = request(object)
  rescue Exception => e
    on_exception(e)
  else
    impl.send_response(message, config.marshaler.marshal(response))
  end
  post_request(object)
rescue Exception => e
  Qwirk.logger.error("Exception in send_response or post_request: #{e.message}")
  log_backtrace(e)
end

#post_request(object) ⇒ Object

Handle any processing that you want to perform after the reply



43
44
# File 'lib/qwirk/reply_worker.rb', line 43

def post_request(object)
end

#request(object) ⇒ Object



38
39
40
# File 'lib/qwirk/reply_worker.rb', line 38

def request(object)
  raise "#{self}: Need to override request method in #{self.class.name} in order to act on #{object}"
end