delayed_job_groups_plugin 0.13.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9773f978178a522b2f7d150230d2aec54bdd5a3bd11b13a980e93ebd71a0bf8c
4
- data.tar.gz: 9d7ae98668fc83a5d7aa516138470585dc5f711a52796c297f8c408969cb2903
3
+ metadata.gz: 9d88649deb9812581de80f6a57a265ccfd265f7f9122d837eff527647f77f01b
4
+ data.tar.gz: 4979b4dd43fb9294fb622e478ac5bb36a7f688f83236183eac2fc80a668af828
5
5
  SHA512:
6
- metadata.gz: 964f5ea0c140c4d9122ed4602e2e059263f8e2ba71242aa741f079a195a8f7a39c42938380b8794f40b7ebb0b464c640ae1945c7a4174150d5299df9af381bd0
7
- data.tar.gz: 98ff4ae8816c181e05aea9ad267d105e0d0397f3d02a50ef7fa3c61bfc9c53100d8e0a3a10aee298b512ae80a55f753f08e7407dafaabfaf6f5f40080428f600
6
+ metadata.gz: '083c6e1461374569d30d7538fb5a7e4d4f980cae04858bbac94793597f62d588a6078b6e55e605ee7e10ff413e0c6ef5460088cd50667663ceefdfc29543ae6a'
7
+ data.tar.gz: d4ede12f4275b606f0e0704ac3cfc255727f3796979ecff7aa87781629172d0e15ad6e1d0b96254bd845f243a7f8d7bc96f4c4bb670bf4d48be4e4a2590776a4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.0
4
+ ### Breaking Changes
5
+ - This library will fail to load if `Delayed::Worker.destroy_failed_jobs` is set to true.
6
+ Delayed::Job sets this option to true by default, you will need to configure it to false
7
+ in order to include this library.
8
+ ### Changes
9
+ - Moves `on_cancellation` logic from the before delayed job lifecycle hook to the after hook.
10
+ - Wrapped the job group cancel hook in a lock to prevent concurrently failing jobs from enqueueing
11
+ multiple on cancellation jobs.
12
+
13
+ ## 0.14.0
14
+ - Reverts changes made in version 0.13.
15
+
3
16
  ## 0.13.0
4
17
  - Moves `on_cancellation` logic from the before delayed job lifecycle hook to the after hook.
5
18
  - Gem will now fail to load if `Delayed::Worker.destroy_failed_jobs` is set to true.
data/README.md CHANGED
@@ -35,6 +35,15 @@ Run the required database migrations:
35
35
  $ rails generate delayed_job_groups_plugin:install
36
36
  $ rake db:migrate
37
37
 
38
+ ## Upgrading from 0.14.0
39
+
40
+ This library is now incompatible with Delayed::Job's default setting for `destroy_failed_jobs`.
41
+ In order to use Delayed Job Groups, you must set it to false while configuring Delayed::Job:
42
+
43
+ ```ruby
44
+ Delayed::Worker.destroy_failed_jobs = false
45
+ ```
46
+
38
47
  ## Upgrading from 0.1.2
39
48
  run the following generator to create a migration for the new configuration column.
40
49
 
@@ -42,6 +51,7 @@ run the following generator to create a migration for the new configuration colu
42
51
  # add `default: true, null: false` to the generated migration for the failure_cancels_group column
43
52
  $ rake db:migrate
44
53
 
54
+
45
55
  ## Usage
46
56
 
47
57
  Creating a job group and queueing some jobs:
@@ -11,7 +11,9 @@ module Delayed
11
11
  # complete the group instead of the group being cancelled. Therefore, we must ensure that
12
12
  # the Delayed::Worker.destroy_failed_jobs is set to false, guaranteeing that the group is
13
13
  # never empty if failure occurs.
14
- raise Delayed::JobGroups::IncompatibleWithDelayedJobError if Delayed::Worker.destroy_failed_jobs
14
+ if Delayed::Worker.destroy_failed_jobs && ActiveRecord::Base.connection.table_exists?(:delayed_job_groups)
15
+ raise Delayed::JobGroups::IncompatibleWithDelayedJobError
16
+ end
15
17
 
16
18
  Delayed::Backend::ActiveRecord::Job.include(Delayed::JobGroups::JobExtensions)
17
19
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Delayed
4
4
  module JobGroups
5
- VERSION = '0.13.0'
5
+ VERSION = '1.0.0'
6
6
  end
7
7
  end
@@ -18,5 +18,37 @@ module DelayedJobGroupsPlugin
18
18
  ActiveRecord::Generators::Base.next_migration_number(dirname)
19
19
  end
20
20
 
21
+ def create_initializer
22
+ initializer_file = File.join('config/initializers', 'delayed_job_config.rb')
23
+ configuration_on_matcher = /Delayed::Worker\.destroy_failed_jobs\s*=\s*true/
24
+ configuration_off_matcher = /Delayed::Worker\.destroy_failed_jobs\s*=\s*false/
25
+
26
+ say 'Attempting to initialize delayed_job_config initializer...', :green
27
+
28
+ if File.exist?(initializer_file)
29
+ say 'delayed_job_config initializer already exists... checking destroy_failed_jobs options', :green
30
+ contents = File.read(initializer_file)
31
+ if contents.match(configuration_on_matcher)
32
+ say 'Delayed::Worker.destroy_failed_jobs is set to true', :red
33
+ say 'This library requires the option to be set to false, updating config now!', :yellow
34
+
35
+ gsub_file initializer_file, configuration_on_matcher, 'Delayed::Worker.destroy_failed_jobs = false'
36
+ elsif contents.match(configuration_off_matcher)
37
+ say 'Delayed::Worker.destroy_failed_jobs is set to false; nothing to do!', :green
38
+ else
39
+ say 'Delayed::Worker.destroy_failed_jobs is not set'
40
+ say 'This library requires the option to be set to false, updating config now!', :yellow
41
+ inject_into_file initializer_file, "Delayed::Worker.destroy_failed_jobs = false\n"
42
+ end
43
+ else
44
+ create_file initializer_file do
45
+ <<~RUBY
46
+ # frozen_string_literal: true
47
+
48
+ Delayed::Worker.destroy_failed_jobs = false
49
+ RUBY
50
+ end
51
+ end
52
+ end
21
53
  end
22
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_job_groups_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Turkel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-09-24 00:00:00.000000000 Z
12
+ date: 2025-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord