lib/good_job.rb in good_job-3.20.0 vs lib/good_job.rb in good_job-3.21.0
- old
+ new
@@ -40,10 +40,14 @@
#
# +GoodJob+ is the top-level namespace and exposes configuration attributes.
module GoodJob
include GoodJob::Dependencies
+ # Default, null, blank value placeholder.
+ NONE = Module.new.freeze
+
+ # Default logger for GoodJob; overridden by Rails.logger in Railtie.
DEFAULT_LOGGER = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new($stdout))
# @!attribute [rw] active_record_parent_class
# @!scope class
# The ActiveRecord parent class inherited by +GoodJob::Execution+ (default: +ActiveRecord::Base+).
@@ -231,16 +235,22 @@
# Perform all queued jobs in the current thread.
# This is primarily intended for usage in a test environment.
# Unhandled job errors will be raised.
# @param queue_string [String] Queues to execute jobs from
+ # @param limit [Integer, nil] Maximum number of iterations for the loop
# @return [void]
- def self.perform_inline(queue_string = "*")
+ def self.perform_inline(queue_string = "*", limit: nil)
job_performer = JobPerformer.new(queue_string)
+ iteration = 0
loop do
+ break if limit && iteration >= limit
+
result = Rails.application.reloader.wrap { job_performer.next }
break unless result
raise result.unhandled_error if result.unhandled_error
+
+ iteration += 1
end
end
# Deprecator for providing deprecation warnings.
# @return [ActiveSupport::Deprecation]