Method: Workling::Invokers::ThreadedPoller#dispatch!
- Defined in:
- lib/workling/invokers/threaded_poller.rb
#dispatch!(connection, clazz) ⇒ Object
Dispatcher for one worker class. Will throw MemCacheError if unable to connect. Returns the number of worker methods called
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/workling/invokers/threaded_poller.rb', line 127 def dispatch!(connection, clazz) n = 0 for queue in @routing.queue_names_routing_class(clazz) begin result = connection.retrieve(queue) if result n += 1 handler = @routing[queue] method_name = @routing.method_name(queue) logger.debug("Calling #{handler.class.to_s}\##{method_name}(#{result.inspect})") handler.dispatch_to_worker_method(method_name, result) end rescue Workling::WorklingError => e logger.error("FAILED to connect with queue #{ queue }: #{ e } }") raise e end end return n end |