lib/good_job/poller.rb in good_job-1.9.3 vs lib/good_job/poller.rb in good_job-1.9.4

- old
+ new

@@ -14,11 +14,11 @@ }.freeze # @!attribute [r] instances # @!scope class # List of all instantiated Pollers in the current process. - # @return [Array<GoodJob::Poller>] + # @return [Array<GoodJob::Poller>, nil] cattr_reader :instances, default: [], instance_reader: false # Creates GoodJob::Poller from a GoodJob::Configuration instance. # @param configuration [GoodJob::Configuration] # @return [GoodJob::Poller] @@ -28,12 +28,12 @@ # List of recipients that will receive notifications. # @return [Array<#call, Array(Object, Symbol)>] attr_reader :recipients - # @param recipients [Array<#call, Array(Object, Symbol)>] - # @param poll_interval [Hash] number of seconds between polls + # @param recipients [Array<Proc, #call, Array(Object, Symbol)>] + # @param poll_interval [Integer, nil] number of seconds between polls def initialize(*recipients, poll_interval: nil) @recipients = Concurrent::Array.new(recipients) @timer_options = DEFAULT_TIMER_OPTIONS.dup @timer_options[:execution_interval] = poll_interval if poll_interval.present? @@ -70,28 +70,33 @@ end end # Restart the poller. # When shutdown, start; or shutdown and start. - # @param timeout [nil, Numeric] Seconds to wait; shares same values as {#shutdown}. + # @param timeout [Numeric, nil] Seconds to wait; shares same values as {#shutdown}. # @return [void] def restart(timeout: -1) shutdown(timeout: timeout) if running? create_timer end # Invoked on completion of TimerTask task. # @!visibility private + # @param time [Integer] + # @param executed_task [Object, nil] + # @param thread_error [Exception, nil] # @return [void] def timer_observer(time, executed_task, thread_error) GoodJob.on_thread_error.call(thread_error) if thread_error && GoodJob.on_thread_error.respond_to?(:call) ActiveSupport::Notifications.instrument("finished_timer_task", { result: executed_task, error: thread_error, time: time }) end private + # @return [Concurrent::TimerTask] attr_reader :timer + # @return [void] def create_timer return if @timer_options[:execution_interval] <= 0 @timer = Concurrent::TimerTask.new(@timer_options) do recipients.each do |recipient|