Sha256: f88b0c2e0650e61f2c3526ad40f1ef02eb3181db50d592ea2efa136918068c55
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
module FakeSQS QueueNameExists = Class.new(RuntimeError) NonExistentQueue = Class.new(RuntimeError) class Queues attr_reader :queue_factory, :database def initialize(options = {}) @queue_factory = options.fetch(:queue_factory) @database = options.fetch(:database) @database.load end def create(name, options = {}) if database[name] fail QueueNameExists, name else queue = queue_factory.new(options) database[name] = queue end end def delete(name, options = {}) if database[name] database.delete(name) else fail NonExistentQueue, name end end def list(options = {}) if (prefix = options["QueueNamePrefix"]) database.select { |name, queue| name.start_with?(prefix) }.values else database.values end end def get(name, options = {}) if (db = database[name]) db else fail NonExistentQueue, name end end def transaction database.transaction do yield end end def save(queue) database[queue.name] = queue end def reset database.reset end def timeout_messages! transaction do database.each { |name,queue| queue.timeout_messages! } end end def expire transaction do database.each { |name, queue| queue.expire } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fake_sqs-0.3.0 | lib/fake_sqs/queues.rb |
fake_sqs-0.2.0 | lib/fake_sqs/queues.rb |
fake_sqs-0.1.0 | lib/fake_sqs/queues.rb |