Sha256: 9047505bcc876ec02b5fbc8fe4e47fb709c27856ae9298ff62a201e4f113dfd1

Contents?: true

Size: 526 Bytes

Versions: 2

Compression:

Stored size: 526 Bytes

Contents

module EMJack
  module Handler
    class Errors
      RESPONSE = /^(OUT_OF_MEMORY|INTERNAL_ERROR|DRAINING|BAD_FORMAT|UNKNOWN_COMMAND|EXPECTED_CRLF|JOB_TOO_BIG|DEADLINE_SOON|TIMED_OUT|NOT_FOUND)\r\n/i

      def self.handles?(response)
        response =~ RESPONSE
      end

      def self.handle(deferrable, response, body)
        return false unless response =~ RESPONSE
        deferrable.fail($1.downcase.to_sym)
        true
      end

      EMJack::Connection.register_handler(EMJack::Handler::Errors)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-jack-0.0.6 lib/em-jack/handlers/errors.rb
em-jack-0.0.5 lib/em-jack/handlers/errors.rb