lib/toiler/actor/fetcher.rb in toiler-0.4.3 vs lib/toiler/actor/fetcher.rb in toiler-0.5.0

- old
+ new

@@ -70,22 +70,27 @@ def max_messages batch? ? FETCH_LIMIT : [FETCH_LIMIT, free_processors.value].min end def poll_future - Concurrent.future do + Concurrent::Promises.future do queue.receive_messages message_attribute_names: %w(All), wait_time_seconds: wait, max_number_of_messages: max_messages end end def poll_messages return unless polling.make_true - poll_future.on_completion! do |success, msgs, error| + poll_future.on_rejection! do polling.make_false scheduled.make_false - if success && !msgs.nil? && !msgs.empty? + tell :schedule_poll + end + poll_future.on_fulfillment! do |msgs| + polling.make_false + scheduled.make_false + if !msgs.nil? && !msgs.empty? tell [:assign_messages, msgs] else tell :schedule_poll end end