Sha256: 18500cfb6f17dab99cc76185a95b3e56b9207707a284eab46fc6d42664acbc6e

Contents?: true

Size: 608 Bytes

Versions: 2

Compression:

Stored size: 608 Bytes

Contents

module MessageQueue
  class Kestrel < Base
    attr_reader :client, :servers

    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)
      client.set(queue, data)
    end

    def dequeue(queue)
      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
famoseagle-sweat_shop-0.5.0 lib/message_queue/kestrel.rb
famoseagle-sweat_shop-0.6.0 lib/message_queue/kestrel.rb