Sha256: 4c395eba3e300ee9dcf65bc8ae9b59599d7fa6b4cedfda7a3a0f13738ee81537
Contents?: true
Size: 1.01 KB
Versions: 26
Compression:
Stored size: 1.01 KB
Contents
class Freddy module MessageHandlerAdapters class Factory def initialize(producer) @no_op_handler = NoOpHandler.new @request_handler = RequestHandler.new(producer) end def for(delivery) if delivery.type == 'request' @request_handler else @no_op_handler end end end class NoOpHandler def success(*) # NOP end def error(*) # NOP end end class RequestHandler def initialize(producer) @producer = producer end def success(delivery, response) send_response(delivery, response, type: 'success') end def error(delivery, response) send_response(delivery, response, type: 'error') end private def send_response(delivery, response, opts = {}) @producer.produce delivery.reply_to.force_encoding('utf-8'), response, { correlation_id: delivery.correlation_id }.merge(opts) end end end end
Version data entries
26 entries across 26 versions & 2 rubygems