lib/fake_sqs/api.rb in fake_sqs-0.0.11 vs lib/fake_sqs/api.rb in fake_sqs-0.1.0
- old
+ new
@@ -1,5 +1,6 @@
+require 'fake_sqs/actions/change_message_visibility'
require 'fake_sqs/actions/create_queue'
require 'fake_sqs/actions/delete_queue'
require 'fake_sqs/actions/list_queues'
require 'fake_sqs/actions/get_queue_url'
require 'fake_sqs/actions/send_message'
@@ -19,10 +20,17 @@
attr_reader :queues, :options
def initialize(options = {})
@queues = options.fetch(:queues)
@options = options
+ @run_timer = true
+ @timer = Thread.new do
+ while @run_timer
+ queues.timeout_messages!
+ sleep(5)
+ end
+ end
end
def call(action, *args)
if FakeSQS::Actions.const_defined?(action)
action = FakeSQS::Actions.const_get(action).new(options)
@@ -40,9 +48,13 @@
queues.reset
end
def expire
queues.expire
+ end
+
+ def stop
+ @run_timer = false
end
end
end