lib/good_job.rb in good_job-2.7.1 vs lib/good_job.rb in good_job-2.7.2

- old
+ new

@@ -16,10 +16,12 @@ # GoodJob is a multithreaded, Postgres-based, ActiveJob backend for Ruby on Rails. # # +GoodJob+ is the top-level namespace and exposes configuration attributes. module GoodJob + 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+). # Use this when using multiple databases or other custom ActiveRecord configuration. # @return [ActiveRecord::Base] @@ -32,11 +34,11 @@ # The logger used by GoodJob (default: +Rails.logger+). # Use this to redirect logs to a special location or file. # @return [Logger, nil] # @example Output GoodJob logs to a file: # GoodJob.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new("log/my_logs.log")) - mattr_accessor :logger, default: ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new($stdout)) + mattr_accessor :logger, default: DEFAULT_LOGGER # @!attribute [rw] preserve_job_records # @!scope class # Whether to preserve job records in the database after they have finished (default: +false+). # By default, GoodJob deletes job records after the job is completed successfully. @@ -63,9 +65,16 @@ # @example Send errors to Sentry # # config/initializers/good_job.rb # GoodJob.on_thread_error = -> (exception) { Raven.capture_exception(exception) } # @return [Proc, nil] mattr_accessor :on_thread_error, default: nil + + # Called with exception when a GoodJob thread raises an exception + # @param exception [Exception] Exception that was raised + # @return [void] + def self._on_thread_error(exception) + on_thread_error.call(exception) if on_thread_error.respond_to?(:call) + end # Stop executing jobs. # GoodJob does its work in pools of background threads. # When forking processes you should shut down these background threads before forking, and restart them after forking. # For example, you should use +shutdown+ and +restart+ when using async execution mode with Puma.