delayed_job_groups_plugin 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40f1d73ab96a59d9a844454f73355c43fe4adece
4
- data.tar.gz: d3f901a08c15556844f649ec5c63d2ebc8f5ae7f
3
+ metadata.gz: fcacb139c1ffff95f731afd57e50c3a32efc5952
4
+ data.tar.gz: d2693d1526a5e8bd6a00d228deee56bf6f7dfd71
5
5
  SHA512:
6
- metadata.gz: 3b440e778b155e86b9ed22d00b4737b3d16ab951abffae076614ffea30d7e55cead394a51977b4e23b1f7458eda130b47963360cc6dd0aa38e49b939e3c03a68
7
- data.tar.gz: 3855f98e948a154ef67918f1ef8f370da4ab3d6f01a9382a723d530e526e350d0ddbafa613adebd3ed8251b5a4dec35e90d2dd5986d83851d95e6c4d9ec791ca
6
+ metadata.gz: 9de8e698308f1db0c13873b4d72cfe5497e58252e36140a22a4f36db4dd863df85eb947feb3e7cd4fc9405eba47a244b43517208ab24cb868afd94cfc50a440d
7
+ data.tar.gz: 50abccef280bc1a0342e3d4bae3a1bfed10f3214f55ccced57424fc9d836ee31d4d887b5a4220db4e413d301f63d42b75ea4d176b950ff498405849106cbe36c
@@ -1,10 +1,20 @@
1
1
  language: ruby
2
2
  env:
3
- matrix:
4
- - RAILS_VERSION="~> 3.2.19" JRUBY_OPTS="$JRUBY_OPTS --debug"
5
- - RAILS_VERSION="~> 4.0.10" JRUBY_OPTS="$JRUBY_OPTS --debug"
3
+ - RAILS_VERSION="~> 3.2.21" JRUBY_OPTS="$JRUBY_OPTS --debug"
4
+ - RAILS_VERSION="~> 4.0.13" JRUBY_OPTS="$JRUBY_OPTS --debug"
5
+ - RAILS_VERSION="~> 4.1.9" JRUBY_OPTS="$JRUBY_OPTS --debug"
6
+ - RAILS_VERSION="~> 4.2.0" JRUBY_OPTS="$JRUBY_OPTS --debug"
6
7
  rvm:
7
8
  - 1.9.3
8
9
  - 2.0.0
9
10
  - 2.1.0
11
+ - 2.2.0
10
12
  - jruby-19mode
13
+ matrix:
14
+ exclude:
15
+ # See https://github.com/salsify/goldiloader/issues/22
16
+ - rvm: jruby-19mode
17
+ env: RAILS_VERSION="~> 4.2.0" JRUBY_OPTS="$JRUBY_OPTS --debug"
18
+ # See https://github.com/rails/rails/pull/18306
19
+ - rvm: 2.2.0
20
+ env: RAILS_VERSION="~> 3.2.21" JRUBY_OPTS="$JRUBY_OPTS --debug"
@@ -1,4 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.1.3 (Unreleased)
4
+
5
+ ### 0.1.2
6
+ * Add configuration option to allow failed jobs not to cancel a group.
7
+
3
8
  ### 0.1.1
4
9
  * Update the run_at for all jobs in a JobGroup when it's unblocked.
data/README.md CHANGED
@@ -35,6 +35,13 @@ 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.1.2
39
+ run the following generator to create a migration for the new configuration column.
40
+
41
+ $ rails generate migration add_failure_cancels_group_to_delayed_job_groups failure_cancels_group:boolean
42
+ # add `default: true, null: false` to the generated migration for the failure_cancels_group column
43
+ $ rake db:migrate
44
+
38
45
  ## Usage
39
46
 
40
47
  Creating a job group and queueing some jobs:
@@ -91,6 +98,12 @@ job_group = Delayed::JobGroups::JobGroup.create!
91
98
  job_group.cancel
92
99
  ```
93
100
 
101
+ Configuration to allow failed jobs not to cancel the group
102
+ ```ruby
103
+ # We can optionally pass options that will allow jobs to fail without cancelling the group
104
+ job_group = Delayed::JobGroups::JobGroup.create!(failure_cancels_group: false)
105
+ ```
106
+
94
107
  ## Supported Platforms
95
108
 
96
109
  * Only the Delayed Job Active Record backend is supported.
@@ -6,8 +6,8 @@ require 'delayed/job_groups/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'delayed_job_groups_plugin'
8
8
  spec.version = Delayed::JobGroups::VERSION
9
- spec.authors = ['Joel Turkel']
10
- spec.email = ['jturkel@salsify.com']
9
+ spec.authors = ['Joel Turkel', 'Randy Burkes']
10
+ spec.email = ['jturkel@salsify.com', 'rlburkes@gmail.com']
11
11
  spec.description = %q{Aggregates Delayed::Job jobs into groups with group level management and lifecycle callbacks}
12
12
  spec.summary = %q{Delayed::Job job groups plugin}
13
13
  spec.homepage = 'https://github.com/salsify/delayed_job_groups_plugin'
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.add_dependency 'delayed_job', '>= 3.0'
21
21
  spec.add_dependency 'delayed_job_active_record', '>= 0.4'
22
22
 
23
+ spec.post_install_message = 'See https://github.com/salsify/delayed_job_groups_plugin#installation for upgrade/installation notes.'
24
+
23
25
  spec.add_development_dependency 'activerecord', ENV.fetch('RAILS_VERSION', ['>= 3.2', '< 4.1'])
24
26
  spec.add_development_dependency 'coveralls'
25
27
  spec.add_development_dependency 'database_cleaner', '>= 1.2'
@@ -8,7 +8,7 @@ module Delayed
8
8
 
9
9
  if Delayed::JobGroups::Compatibility.mass_assignment_security_enabled?
10
10
  attr_accessible :on_completion_job, :on_completion_job_options, :blocked, :on_cancellation_job,
11
- :on_cancellation_job_options
11
+ :on_cancellation_job_options, :failure_cancels_group
12
12
  end
13
13
 
14
14
  serialize :on_completion_job
@@ -16,7 +16,7 @@ module Delayed
16
16
  serialize :on_cancellation_job
17
17
  serialize :on_cancellation_job_options, Hash
18
18
 
19
- validates :queueing_complete, :blocked, inclusion: [true, false]
19
+ validates :queueing_complete, :blocked, :failure_cancels_group, inclusion: [true, false]
20
20
 
21
21
  if ActiveRecord::VERSION::MAJOR >= 4
22
22
  has_many :active_jobs, -> { where(failed_at: nil) }, class_name: Job
@@ -34,7 +34,7 @@ module Delayed
34
34
  # If a job in the job group fails, then cancel the whole job group.
35
35
  # Need to check that the job group is present since another
36
36
  # job may have concurrently cancelled it.
37
- if job.in_job_group? && job.job_group
37
+ if job.in_job_group? && job.job_group && job.job_group.failure_cancels_group?
38
38
  job.job_group.cancel
39
39
  end
40
40
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Delayed
4
4
  module JobGroups
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  end
@@ -21,6 +21,7 @@ class CreateDelayedJobGroups < ActiveRecord::Migration
21
21
  t.text :on_completion_job_options
22
22
  t.text :on_cancellation_job
23
23
  t.text :on_cancellation_job_options
24
+ t.boolean :failure_cancels_group, default: true, null: false
24
25
  t.boolean :queueing_complete, default: false, null: false
25
26
  t.boolean :blocked, default: false, null: false
26
27
  end
@@ -23,6 +23,7 @@ ActiveRecord::Schema.define(:version => 0) do
23
23
  t.text :on_completion_job_options
24
24
  t.text :on_cancellation_job
25
25
  t.text :on_cancellation_job_options
26
+ t.boolean :failure_cancels_group, default: true, null: false
26
27
  t.boolean :queueing_complete, default: false, null: false
27
28
  t.boolean :blocked, default: false, null: false
28
29
  end
@@ -225,4 +225,26 @@ describe Delayed::JobGroups::JobGroup do
225
225
  running_job.should_not have_been_destroyed
226
226
  end
227
227
  end
228
+
229
+ describe "#failure_cancels_group?" do
230
+ let(:failure_cancels_group) { true }
231
+
232
+ before do
233
+ job_group.update_attributes!(failure_cancels_group: failure_cancels_group)
234
+ end
235
+
236
+ context "when failures should cancel the group" do
237
+ it "returns true" do
238
+ expect(job_group.failure_cancels_group?).to be true
239
+ end
240
+ end
241
+
242
+ context "when failures should not cancel the group" do
243
+ let(:failure_cancels_group) { false }
244
+
245
+ it "returns false" do
246
+ expect(job_group.failure_cancels_group?).to be false
247
+ end
248
+ end
249
+ end
228
250
  end
@@ -74,21 +74,48 @@ describe Delayed::JobGroups::Plugin do
74
74
  queued_job_count.should eq 0
75
75
  end
76
76
 
77
- it "cancels the job group if a job fails" do
78
- Delayed::Worker.max_attempts = 1
77
+ describe "job failures" do
78
+
79
+ context "with failure_cancels_group enabled" do
80
+ it "cancels the group" do
81
+ Delayed::Worker.max_attempts = 1
82
+
83
+ job_group.enqueue(FailingJob.new)
84
+ job_group.enqueue(NoOpJob.new)
85
+ job_group.mark_queueing_complete
86
+ queued_job_count.should eq 2
87
+ job_group_count.should eq 1
88
+
89
+ # Run the job which should fail and cancel the JobGroup
90
+ Delayed::Worker.new.work_off(1)
91
+ CompletionJob.invoked.should be_false
92
+ failed_job_count.should eq 1
93
+ queued_job_count.should eq 0
94
+ job_group_count.should eq 0
95
+ end
96
+ end
79
97
 
80
- job_group.enqueue(FailingJob.new)
81
- job_group.enqueue(NoOpJob.new)
82
- job_group.mark_queueing_complete
83
- queued_job_count.should eq 2
84
- job_group_count.should eq 1
98
+ context "with failure_cancels_group disabled" do
85
99
 
86
- # Run the job which should fail and cancel the JobGroup
87
- Delayed::Worker.new.work_off(1)
88
- CompletionJob.invoked.should be_false
89
- failed_job_count.should eq 1
90
- queued_job_count.should eq 0
91
- job_group_count.should eq 0
100
+ before { job_group.update_attributes!(failure_cancels_group: false) }
101
+
102
+ it "does not cancel the group" do
103
+ Delayed::Worker.max_attempts = 1
104
+
105
+ job_group.enqueue(FailingJob.new)
106
+ job_group.enqueue(NoOpJob.new)
107
+ job_group.mark_queueing_complete
108
+ queued_job_count.should eq 2
109
+ job_group_count.should eq 1
110
+
111
+ # Run the job which should fail don't cancel the JobGroup
112
+ Delayed::Worker.new.work_off(1)
113
+ CancellationJob.invoked.should be_false
114
+ failed_job_count.should eq 1
115
+ queued_job_count.should eq 1
116
+ job_group_count.should eq 1
117
+ end
118
+ end
92
119
  end
93
120
 
94
121
  it "doesn't retry failed jobs if the job group has been canceled" do
metadata CHANGED
@@ -1,178 +1,180 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_job_groups_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Turkel
8
+ - Randy Burkes
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-10-01 00:00:00.000000000 Z
12
+ date: 2015-02-26 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: delayed_job
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - '>='
18
+ - - ">="
18
19
  - !ruby/object:Gem::Version
19
20
  version: '3.0'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - '>='
25
+ - - ">="
25
26
  - !ruby/object:Gem::Version
26
27
  version: '3.0'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: delayed_job_active_record
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - '>='
32
+ - - ">="
32
33
  - !ruby/object:Gem::Version
33
34
  version: '0.4'
34
35
  type: :runtime
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - '>='
39
+ - - ">="
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0.4'
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: activerecord
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
- - - '>='
46
+ - - ">="
46
47
  - !ruby/object:Gem::Version
47
48
  version: '3.2'
48
- - - <
49
+ - - "<"
49
50
  - !ruby/object:Gem::Version
50
51
  version: '4.1'
51
52
  type: :development
52
53
  prerelease: false
53
54
  version_requirements: !ruby/object:Gem::Requirement
54
55
  requirements:
55
- - - '>='
56
+ - - ">="
56
57
  - !ruby/object:Gem::Version
57
58
  version: '3.2'
58
- - - <
59
+ - - "<"
59
60
  - !ruby/object:Gem::Version
60
61
  version: '4.1'
61
62
  - !ruby/object:Gem::Dependency
62
63
  name: coveralls
63
64
  requirement: !ruby/object:Gem::Requirement
64
65
  requirements:
65
- - - '>='
66
+ - - ">="
66
67
  - !ruby/object:Gem::Version
67
68
  version: '0'
68
69
  type: :development
69
70
  prerelease: false
70
71
  version_requirements: !ruby/object:Gem::Requirement
71
72
  requirements:
72
- - - '>='
73
+ - - ">="
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
76
  - !ruby/object:Gem::Dependency
76
77
  name: database_cleaner
77
78
  requirement: !ruby/object:Gem::Requirement
78
79
  requirements:
79
- - - '>='
80
+ - - ">="
80
81
  - !ruby/object:Gem::Version
81
82
  version: '1.2'
82
83
  type: :development
83
84
  prerelease: false
84
85
  version_requirements: !ruby/object:Gem::Requirement
85
86
  requirements:
86
- - - '>='
87
+ - - ">="
87
88
  - !ruby/object:Gem::Version
88
89
  version: '1.2'
89
90
  - !ruby/object:Gem::Dependency
90
91
  name: rake
91
92
  requirement: !ruby/object:Gem::Requirement
92
93
  requirements:
93
- - - '>='
94
+ - - ">="
94
95
  - !ruby/object:Gem::Version
95
96
  version: '0'
96
97
  type: :development
97
98
  prerelease: false
98
99
  version_requirements: !ruby/object:Gem::Requirement
99
100
  requirements:
100
- - - '>='
101
+ - - ">="
101
102
  - !ruby/object:Gem::Version
102
103
  version: '0'
103
104
  - !ruby/object:Gem::Dependency
104
105
  name: rspec
105
106
  requirement: !ruby/object:Gem::Requirement
106
107
  requirements:
107
- - - '>='
108
+ - - ">="
108
109
  - !ruby/object:Gem::Version
109
110
  version: '2.14'
110
- - - <
111
+ - - "<"
111
112
  - !ruby/object:Gem::Version
112
113
  version: '2.99'
113
114
  type: :development
114
115
  prerelease: false
115
116
  version_requirements: !ruby/object:Gem::Requirement
116
117
  requirements:
117
- - - '>='
118
+ - - ">="
118
119
  - !ruby/object:Gem::Version
119
120
  version: '2.14'
120
- - - <
121
+ - - "<"
121
122
  - !ruby/object:Gem::Version
122
123
  version: '2.99'
123
124
  - !ruby/object:Gem::Dependency
124
125
  name: simplecov
125
126
  requirement: !ruby/object:Gem::Requirement
126
127
  requirements:
127
- - - ~>
128
+ - - "~>"
128
129
  - !ruby/object:Gem::Version
129
130
  version: 0.7.1
130
131
  type: :development
131
132
  prerelease: false
132
133
  version_requirements: !ruby/object:Gem::Requirement
133
134
  requirements:
134
- - - ~>
135
+ - - "~>"
135
136
  - !ruby/object:Gem::Version
136
137
  version: 0.7.1
137
138
  - !ruby/object:Gem::Dependency
138
139
  name: timecop
139
140
  requirement: !ruby/object:Gem::Requirement
140
141
  requirements:
141
- - - '>='
142
+ - - ">="
142
143
  - !ruby/object:Gem::Version
143
144
  version: '0'
144
145
  type: :development
145
146
  prerelease: false
146
147
  version_requirements: !ruby/object:Gem::Requirement
147
148
  requirements:
148
- - - '>='
149
+ - - ">="
149
150
  - !ruby/object:Gem::Version
150
151
  version: '0'
151
152
  - !ruby/object:Gem::Dependency
152
153
  name: sqlite3
153
154
  requirement: !ruby/object:Gem::Requirement
154
155
  requirements:
155
- - - '>='
156
+ - - ">="
156
157
  - !ruby/object:Gem::Version
157
158
  version: '0'
158
159
  type: :development
159
160
  prerelease: false
160
161
  version_requirements: !ruby/object:Gem::Requirement
161
162
  requirements:
162
- - - '>='
163
+ - - ">="
163
164
  - !ruby/object:Gem::Version
164
165
  version: '0'
165
166
  description: Aggregates Delayed::Job jobs into groups with group level management
166
167
  and lifecycle callbacks
167
168
  email:
168
169
  - jturkel@salsify.com
170
+ - rlburkes@gmail.com
169
171
  executables: []
170
172
  extensions: []
171
173
  extra_rdoc_files: []
172
174
  files:
173
- - .gitignore
174
- - .rspec
175
- - .travis.yml
175
+ - ".gitignore"
176
+ - ".rspec"
177
+ - ".travis.yml"
176
178
  - CHANGELOG.md
177
179
  - Gemfile
178
180
  - LICENSE.txt
@@ -197,23 +199,24 @@ homepage: https://github.com/salsify/delayed_job_groups_plugin
197
199
  licenses:
198
200
  - MIT
199
201
  metadata: {}
200
- post_install_message:
202
+ post_install_message: See https://github.com/salsify/delayed_job_groups_plugin#installation
203
+ for upgrade/installation notes.
201
204
  rdoc_options: []
202
205
  require_paths:
203
206
  - lib
204
207
  required_ruby_version: !ruby/object:Gem::Requirement
205
208
  requirements:
206
- - - '>='
209
+ - - ">="
207
210
  - !ruby/object:Gem::Version
208
211
  version: '0'
209
212
  required_rubygems_version: !ruby/object:Gem::Requirement
210
213
  requirements:
211
- - - '>='
214
+ - - ">="
212
215
  - !ruby/object:Gem::Version
213
216
  version: '0'
214
217
  requirements: []
215
218
  rubyforge_project:
216
- rubygems_version: 2.2.2
219
+ rubygems_version: 2.4.5
217
220
  signing_key:
218
221
  specification_version: 4
219
222
  summary: Delayed::Job job groups plugin