episode-130/mailit/vendor/plugins/workling/lib/workling/starling/poller.rb
# Dispatcher for one worker class. Will throw MemCacheError if unable to connect.
# Returns the number of worker methods called
Dispatcher for one worker class. Will throw MemCacheError if unable to connect.
Returns the number of worker methods called
Dispatcher for one worker class . Will throw MemCacheError if unable to connect . Returns the number of worker methods called
def dispatch!(connection, clazz)
        n = 0
        for queue in @routing.queue_names_routing_class(clazz)
          begin
            result = connection.get(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.send(method_name, result)
            end
          rescue MemCache::MemCacheError => e
            logger.error("FAILED to connect with queue #{ queue }: #{ e } }")
            raise e
          rescue Object => e
            logger.error("FAILED to process queue #{ queue }. #{ @routing[queue] } could not handle invocation of #{ @routing.method_name(queue) } with #{ result.inspect }: #{ e }.\n#{ e.backtrace.join("\n") }")
          end
        end
        return n
      end
def dispatch! ( connection , clazz ) n = 0 for queue in @routing . queue_names_routing_class ( clazz ) begin result = connection . get ( 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 . send ( method_name , result ) end rescue MemCache :: MemCacheError => e logger . error ( "FAILED to connect with queue #{ queue }: #{ e } }" ) raise e rescue Object => e logger . error ( "FAILED to process queue #{ queue }. #{ @routing[queue] } could not handle invocation of #{ @routing.method_name(queue) } with #{ result.inspect }: #{ e }.\n#{ e.backtrace.join("\n") }" ) end end return n end
Dispatcher for one worker class.
Dispatcher for one worker class .
connection
clazz