good_job 4.6.0 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,6 +35,8 @@ module GoodJob
35
35
  DEFAULT_DASHBOARD_LIVE_POLL_ENABLED = true
36
36
  # Default enqueue_after_transaction_commit
37
37
  DEFAULT_ENQUEUE_AFTER_TRANSACTION_COMMIT = false
38
+ # Default enable_pauses setting
39
+ DEFAULT_ENABLE_PAUSES = false
38
40
 
39
41
  def self.validate_execution_mode(execution_mode)
40
42
  raise ArgumentError, "GoodJob execution mode must be one of #{EXECUTION_MODES.join(', ')}. It was '#{execution_mode}' which is not valid." unless execution_mode.in?(EXECUTION_MODES)
@@ -369,6 +371,16 @@ module GoodJob
369
371
  DEFAULT_ENQUEUE_AFTER_TRANSACTION_COMMIT
370
372
  end
371
373
 
374
+ # Whether the job processing can be paused.
375
+ # @return [Boolean]
376
+ def enable_pauses
377
+ return options[:enable_pauses] unless options[:enable_pauses].nil?
378
+ return rails_config[:enable_pauses] unless rails_config[:enable_pauses].nil?
379
+ return ActiveModel::Type::Boolean.new.cast(env['GOOD_JOB_ENABLE_PAUSES']) unless env['GOOD_JOB_ENABLE_PAUSE'].nil?
380
+
381
+ DEFAULT_ENABLE_PAUSES
382
+ end
383
+
372
384
  # Whether running in a web server process.
373
385
  # @return [Boolean, nil]
374
386
  def in_webserver?
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GoodJob
4
4
  # GoodJob gem version.
5
- VERSION = '4.6.0'
5
+ VERSION = '4.8.0'
6
6
 
7
7
  # GoodJob version as Gem::Version object
8
8
  GEM_VERSION = Gem::Version.new(VERSION)
data/lib/good_job.rb CHANGED
@@ -292,6 +292,38 @@ module GoodJob
292
292
  def self.migrated?
293
293
  GoodJob::BatchRecord.jobs_finished_at_migrated?
294
294
  end
295
+
296
+ # Pause job execution for a given queue or job class.
297
+ # @param queue [String, nil] Queue name to pause
298
+ # @param job_class [String, nil] Job class name to pause
299
+ # @return [void]
300
+ def self.pause(queue: nil, job_class: nil)
301
+ GoodJob::Setting.pause(queue: queue, job_class: job_class)
302
+ end
303
+
304
+ # Unpause job execution for a given queue or job class.
305
+ # @param queue [String, nil] Queue name to unpause
306
+ # @param job_class [String, nil] Job class name to unpause
307
+ # @param label [String, nil] Label to unpause
308
+ # @return [void]
309
+ def self.unpause(queue: nil, job_class: nil, label: nil)
310
+ GoodJob::Setting.unpause(queue: queue, job_class: job_class, label: label)
311
+ end
312
+
313
+ # Check if job execution is paused for a given queue or job class.
314
+ # @param queue [String, nil] Queue name to check
315
+ # @param job_class [String, nil] Job class name to check
316
+ # @param label [String, nil] Label to check
317
+ # @return [Boolean]
318
+ def self.paused?(queue: nil, job_class: nil, label: nil)
319
+ GoodJob::Setting.paused?(queue: queue, job_class: job_class, label: label)
320
+ end
321
+
322
+ # Get a list of all paused queues and job classes
323
+ # @return [Hash] Hash with :queues, :job_classes, :labels arrays of paused items
324
+ def self.paused(type = nil)
325
+ GoodJob::Setting.paused(type)
326
+ end
295
327
  end
296
328
 
297
329
  ActiveSupport.run_load_hooks(:good_job, GoodJob)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: good_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.0
4
+ version: 4.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-12 00:00:00.000000000 Z
10
+ date: 2025-01-22 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activejob
@@ -259,6 +258,7 @@ files:
259
258
  - app/controllers/good_job/frontends_controller.rb
260
259
  - app/controllers/good_job/jobs_controller.rb
261
260
  - app/controllers/good_job/metrics_controller.rb
261
+ - app/controllers/good_job/pauses_controller.rb
262
262
  - app/controllers/good_job/performance_controller.rb
263
263
  - app/controllers/good_job/processes_controller.rb
264
264
  - app/filters/good_job/base_filter.rb
@@ -313,6 +313,9 @@ files:
313
313
  - app/views/good_job/jobs/_table.erb
314
314
  - app/views/good_job/jobs/index.html.erb
315
315
  - app/views/good_job/jobs/show.html.erb
316
+ - app/views/good_job/pauses/_group.html.erb
317
+ - app/views/good_job/pauses/_pause.html.erb
318
+ - app/views/good_job/pauses/index.html.erb
316
319
  - app/views/good_job/performance/index.html.erb
317
320
  - app/views/good_job/performance/show.html.erb
318
321
  - app/views/good_job/processes/index.html.erb
@@ -396,7 +399,6 @@ metadata:
396
399
  homepage_uri: https://github.com/bensheldon/good_job
397
400
  source_code_uri: https://github.com/bensheldon/good_job
398
401
  rubygems_mfa_required: 'true'
399
- post_install_message:
400
402
  rdoc_options:
401
403
  - "--title"
402
404
  - GoodJob - a multithreaded, Postgres-based ActiveJob backend for Ruby on Rails
@@ -418,8 +420,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
418
420
  - !ruby/object:Gem::Version
419
421
  version: '0'
420
422
  requirements: []
421
- rubygems_version: 3.5.11
422
- signing_key:
423
+ rubygems_version: 3.6.2
423
424
  specification_version: 4
424
425
  summary: A multithreaded, Postgres-based ActiveJob backend for Ruby on Rails
425
426
  test_files: []