Module: StickyElephant::Handler

Defined in:
lib/sticky_elephant/handler.rb,
lib/sticky_elephant/handler/base.rb,
lib/sticky_elephant/handler/quit.rb,
lib/sticky_elephant/handler/error.rb,
lib/sticky_elephant/handler/query.rb,
lib/sticky_elephant/handler/handshake.rb,
lib/sticky_elephant/handler/ssl_request.rb

Defined Under Namespace

Classes: Base, Error, Handshake, Query, Quit, SSLRequest

Constant Summary collapse

TYPES_HANDLERS =
{
  quit:        StickyElephant::Handler::Quit,
  ssl_request: StickyElephant::Handler::SSLRequest,
  query:       StickyElephant::Handler::Query,
  handshake:   StickyElephant::Handler::Handshake,
  invalid:     StickyElephant::Handler::Error,
}

Class Method Summary collapse

Class Method Details

.for(payload, socket:, logger:) ⇒ Object

Raises:

  • (StandardError)


10
11
12
13
14
# File 'lib/sticky_elephant/handler.rb', line 10

def self.for(payload, socket: , logger: )
  klass = TYPES_HANDLERS[payload.type]
  raise StandardError.new("Invalid type #{payload.type} for #{payload}") if klass.nil?
  klass.new(payload, socket: socket, logger: logger)
end