Sha256: acd885120e7d6d970a51a0bc875294c7e2a3ce311e6c0b21b3c6167146267e12
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module CottonTail module Queue # A wrapper around a ::Bunny::Queue that makes it interchangeable with a # standard Ruby::Queue class Bunny def self.call(name:, **opts) new(name, **opts) end def initialize(name, conn: Connection.new, prefetch: 1, manual_ack: false, **opts) @name = name @prefetch = prefetch @conn = conn @queue = conn.queue(@name, **opts) @messages = ::Queue.new @queue.subscribe(manual_ack: manual_ack) { |*args| @messages << args } end def bind(routing_key) @queue.bind('amq.topic', routing_key: routing_key) end def push(args) routing_key, message = args @conn.publish message, routing_key: routing_key end def close @messages.close end def closed? @messages.closed? end def empty? @messages.empty? end def pop delivery_info, *tail = @messages.pop [delivery_info[:routing_key], delivery_info, *tail, conn: @conn] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cotton-tail-0.1.2 | lib/cotton_tail/queue/bunny.rb |