Module: GoodJob
- Defined in:
- lib/good_job.rb,
lib/good_job/cli.rb,
lib/good_job/job.rb,
lib/good_job/poller.rb,
lib/good_job/adapter.rb,
lib/good_job/railtie.rb,
lib/good_job/version.rb,
lib/good_job/lockable.rb,
lib/good_job/notifier.rb,
lib/good_job/performer.rb,
lib/good_job/scheduler.rb,
lib/good_job/configuration.rb,
lib/good_job/log_subscriber.rb,
lib/good_job/multi_scheduler.rb,
lib/good_job/current_execution.rb,
lib/generators/good_job/install_generator.rb
Overview
:nodoc:
Defined Under Namespace
Modules: CurrentExecution, Lockable Classes: Adapter, CLI, Configuration, InstallGenerator, Job, LogSubscriber, MultiScheduler, Notifier, Performer, Poller, Railtie, Scheduler
Constant Summary collapse
- VERSION =
GoodJob gem version.
'1.3.1'.freeze
Class Attribute Summary collapse
-
.logger ⇒ Logger
The logger used by GoodJob (default:
Rails.logger). -
.on_thread_error ⇒ #call?
This callable will be called when an exception reaches GoodJob (default:
nil). -
.preserve_job_records ⇒ Boolean
Whether to preserve job records in the database after they have finished (default:
false). -
.retry_on_unhandled_error ⇒ Boolean
Whether to re-perform a job when a type of
StandardErroris raised to GoodJob (default:true).
Class Method Summary collapse
-
.reperform_jobs_on_standard_error ⇒ Object
deprecated
Deprecated.
Use GoodJob.retry_on_unhandled_error instead.
-
.reperform_jobs_on_standard_error=(value) ⇒ Object
deprecated
Deprecated.
Use GoodJob.retry_on_unhandled_error= instead.
-
.restart ⇒ void
Stops and restarts executing jobs.
-
.shutdown(wait: true) ⇒ void
Stop executing jobs.
-
.shutdown? ⇒ Boolean
Tests whether jobs have stopped executing.
Class Attribute Details
.logger ⇒ Logger
The logger used by GoodJob (default: Rails.logger). Use this to redirect logs to a special location or file.
28 |
# File 'lib/good_job.rb', line 28 mattr_accessor :logger, default: ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new($stdout)) |
.on_thread_error ⇒ #call?
This callable will be called when an exception reaches GoodJob (default: nil). It can be useful for logging errors to bug tracking services, like Sentry or Airbrake.
73 |
# File 'lib/good_job.rb', line 73 mattr_accessor :on_thread_error, default: nil |
.preserve_job_records ⇒ Boolean
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. If you want to preserve jobs for latter inspection, set this to true. If you want to preserve only jobs that finished with error for latter inspection, set this to :on_unhandled_error. If true, you will need to clean out jobs using the good_job cleanup_preserved_jobs CLI command.
38 |
# File 'lib/good_job.rb', line 38 mattr_accessor :preserve_job_records, default: false |
.retry_on_unhandled_error ⇒ Boolean
Whether to re-perform a job when a type of StandardError is raised to GoodJob (default: true). If true, causes jobs to be re-queued and retried if they raise an instance of StandardError. If false, jobs will be discarded or marked as finished if they raise an instance of StandardError. Instances of Exception, like SIGINT, will always be retried, regardless of this attribute’s value.
47 |
# File 'lib/good_job.rb', line 47 mattr_accessor :retry_on_unhandled_error, default: true |
Class Method Details
.reperform_jobs_on_standard_error ⇒ Object
Use retry_on_unhandled_error instead.
50 51 52 53 54 55 |
# File 'lib/good_job.rb', line 50 def self.reperform_jobs_on_standard_error ActiveSupport::Deprecation.warn( "Calling 'GoodJob.reperform_jobs_on_standard_error' is deprecated. Please use 'retry_on_unhandled_error'" ) retry_on_unhandled_error end |
.reperform_jobs_on_standard_error=(value) ⇒ Object
Use retry_on_unhandled_error= instead.
58 59 60 61 62 63 |
# File 'lib/good_job.rb', line 58 def self.reperform_jobs_on_standard_error=(value) ActiveSupport::Deprecation.warn( "Setting 'GoodJob.reperform_jobs_on_standard_error=' is deprecated. Please use 'retry_on_unhandled_error='" ) self.retry_on_unhandled_error = value end |
.restart ⇒ void
This method returns an undefined value.
Stops and restarts 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. See the README for more explanation and examples.
99 100 101 102 |
# File 'lib/good_job.rb', line 99 def self.restart Notifier.instances.each(&:restart) Scheduler.instances.each(&:restart) end |
.shutdown(wait: true) ⇒ void
This method returns an undefined value.
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. See the README for more explanation and examples.
82 83 84 85 |
# File 'lib/good_job.rb', line 82 def self.shutdown(wait: true) Notifier.instances.each { |notifier| notifier.shutdown(wait: wait) } Scheduler.instances.each { |scheduler| scheduler.shutdown(wait: wait) } end |
.shutdown? ⇒ Boolean
Tests whether jobs have stopped executing.
89 90 91 |
# File 'lib/good_job.rb', line 89 def self.shutdown? Notifier.instances.all?(&:shutdown?) && Scheduler.instances.all?(&:shutdown?) end |