Sha256: ecbf1ada6449729350b07d9a37fb5ff8b527207bd450712a508491d0bcaf4653

Contents?: true

Size: 608 Bytes

Versions: 3

Compression:

Stored size: 608 Bytes

Contents

class Freddy
  class AdaptiveQueue
    def initialize(queue)
      @queue = queue
    end

    def subscribe(&block)
      if hare?
        @queue.subscribe do |meta, payload|
          block.call(payload, Delivery.new(meta, meta.routing_key))
        end
      else
        @queue.subscribe do |info, properties, payload|
          block.call(payload, Delivery.new(properties, info.routing_key))
        end
      end
    end

    def bind(*args)
      @queue.bind(*args)
      self
    end

    def name
      @queue.name
    end

    private

    def hare?
      RUBY_PLATFORM == 'java'
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
freddy-0.4.4 lib/freddy/adaptive_queue.rb
freddy-jruby-0.4.3 lib/freddy/adaptive_queue.rb
freddy-0.4.3 lib/freddy/adaptive_queue.rb