Class: EMJack::Handler::Errors

Inherits:
Object
  • Object
show all
Defined in:
lib/em-jack/handlers/errors.rb

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.handle(deferrable, response, body, conn = nil) ⇒ Object



10
11
12
13
14
# File 'lib/em-jack/handlers/errors.rb', line 10

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

.handles?(response) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/em-jack/handlers/errors.rb', line 6

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