Sha256: d7c0cf411cf62680f3d221313779e40e26dd8ff3d87ea2b486d29744d96d22cb

Contents?: true

Size: 598 Bytes

Versions: 2

Compression:

Stored size: 598 Bytes

Contents

module MessageQueue
  class Kestrel < Base
    def initialize(opts)
      @servers = opts['servers']
    end

    def queue_size(queue)
      size  = 0
      stats = client.stats
      servers.each do |server|
        size += stats[server]["queue_#{queue}_items"].to_i
      end
      size
    end

    def enqueue(queue, data, serializer)
      client.set(queue, data)
    end

    def dequeue(queue, serializer)
      client.get("#{queue}/open")
    end

    def confirm(queue)
      client.get("#{queue}/close")
    end

    def client
      @client ||= MemCache.new(servers) 
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netinlet-sweat_shop-1.1.0 lib/message_queue/kestrel.rb
netinlet-sweat_shop-1.1.1 lib/message_queue/kestrel.rb