Sha256: 9e93fd6df54c7c561f96b48bc895e5f4bf316ae1a05350e9b692eafbfdeaf65d
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
module FakeServiceBus 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 = {}) return database[name] if database[name] queue = queue_factory.new(options.merge(:name=>name)) database[name] = queue 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fake_servicebus-0.0.2 | lib/fake_servicebus/queues.rb |