Class: Qwirk::Remote::Worker

Inherits:
Object
  • Object
show all
Includes:
Qwirk::ReplyWorker
Defined in:
lib/qwirk/remote/worker.rb

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

Instance Method Summary collapse

Methods included from Qwirk::ReplyWorker

included, #perform, #post_request

Methods included from Worker

#event_loop, #fail_queue_name, included, #init, #join, #log_backtrace, #on_exception, #on_message, #perform, #start, #stop, #to_s

Methods included from BaseWorker

included, #status, #stop, #to_s, worker_classes

Instance Method Details

#request(hash) ⇒ Object

Process incoming inquiries



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/qwirk/remote/worker.rb', line 11

def request(hash)
  case command = hash['command']
    when 'serialize'
      ::Rumx::Bean.root.bean_to_remote_hash
    when 'operation'
      bean, operation, value = ::Rumx::Bean.run_operation(hash['ancestry'], hash['operation_name'], hash['argument_hash'])
      puts "operation returned #{value}"
      raise "Invalid operation ancestry = #{hash['ancestry'].inspect} operation=#{hash['operation_name'].inspect}" unless bean
      # Allow bson to handle it
      { :value => value }
    when 'attributes'
      bean = ::Rumx::Bean.find(hash['ancestry'])
      raise "Invalid bean ancestry #{hash['ancestry'].inspect}" unless bean
      attributes = bean.bean_set_and_get_attributes(hash['params'])
      puts "attributes returned #{attributes.inspect}"
      attributes
    else
      raise "Invalid command: #{command.inspect}"
  end
end