lib/toiler/actor/fetcher.rb in toiler-0.2.5 vs lib/toiler/actor/fetcher.rb in toiler-0.2.6

- old
+ new

@@ -5,11 +5,11 @@ module Actor # Actor polling for messages only when processors are ready, otherwise idle class Fetcher < Concurrent::Actor::RestartingContext include Utils::ActorLogging - FETCH_LIMIT = 10.freeze + FETCH_LIMIT = 10 attr_accessor :queue, :wait, :visibility_timeout, :free_processors, :scheduled def initialize(queue, client) @@ -22,11 +22,11 @@ @scheduled = Concurrent::AtomicBoolean.new debug "Finished initializing Fetcher for queue #{queue}" end def default_executor - Concurrent.global_fast_executor + Concurrent.global_io_executor end def on_message(msg) method, *args = msg send(method, *args) @@ -57,13 +57,13 @@ max_number_of_messages: max_messages end end def poll_messages - poll_future.on_completion! do |_success, msgs, _reason| - scheduled.make_false + poll_future.on_completion! do |_success, msgs| tell [:assign_messages, msgs] unless msgs.nil? || msgs.empty? - schedule_poll + scheduled.make_false + tell :schedule_poll end end def schedule_poll return unless free_processors.value > 0 && scheduled.make_true