Sha256: 64b39cf3784e04ef169a940c18dbae4e0bee4d8c7ab21fcbc1ae909f658b550a

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require_relative 'responder_handler'
require_relative 'message_handler'
require_relative 'delivery'
require_relative 'consumers/tap_into_consumer'
require_relative 'consumers/respond_to_consumer'
require_relative 'consumers/response_consumer'

class Freddy
  class Consumer
    def initialize(channel, logger, consume_thread_pool, producer)
      @channel, @logger = channel, logger
      @tap_into_consumer = Consumers::TapIntoConsumer.new(consume_thread_pool, channel)
      @respond_to_consumer = Consumers::RespondToConsumer.new(consume_thread_pool, channel, producer, @logger)
      @response_consumer = Consumers::ResponseConsumer.new(@logger)
    end

    def response_consume(queue, &block)
      @logger.debug "Consuming messages on #{queue.name}"
      @response_consumer.consume(queue, &block)
    end

    def tap_into(pattern, &block)
      @logger.debug "Tapping into messages that match #{pattern}"
      @tap_into_consumer.consume(pattern, &block)
    end

    def respond_to(destination, &block)
      @logger.info "Listening for requests on #{destination}"
      @respond_to_consumer.consume(destination, &block)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
freddy-0.4.8 lib/freddy/consumer.rb
freddy-0.4.7 lib/freddy/consumer.rb