sidekiq-superworker 1.0.0 → 1.1.0

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: 53beee36ab3ca54954950636adfc11d3e5d6c8e5
4
- data.tar.gz: 168d1b43b60f7085b1cb5f3185208d88c94effbd
3
+ metadata.gz: a30dd0e4575bf141b1aa0c262df3d08fb21a7745
4
+ data.tar.gz: a6ca0500b339d3c5f75400c9efb58bfbacab5bfe
5
5
  SHA512:
6
- metadata.gz: f9606cbc54a87383c448ab89ba308df8ca4713caa92920a8d9cb4365c7ede28447ba811e5eced133310b8e32b613ff5f3a56afc51e10cc284141ae2f08cdf218
7
- data.tar.gz: f2b6beafee29aec0ed97ecf22f334697ea7c235d2886cbd3c95f668e2a8e009303b617a204082b64777fd171ee668700ac32b3cb44fc8cc16518d1466c5d6ffb
6
+ metadata.gz: 7bb2bc65a5e482cfec52dd8d23a1df3209bb9688d79449e573857076cc2442e5ef17a7769813b437cf4af3d42f4a6057f207b254b604ce16dbc2db41ceb19ecd
7
+ data.tar.gz: a2d9bff3ed22aa146080cb180acc007aaae88261af333b399cf56f8129d467cd9304e15d8449218949072ea69d542c573c749e6d783c259afa9572e97095f8cd
data/README.md CHANGED
@@ -129,7 +129,7 @@ end
129
129
 
130
130
  #### Delete subjobs after their superjob completes
131
131
 
132
- When a superjob is queued, records for all of its subjobs are created. By default these records are deleted when the superjob finished. This can be changed by setting the following option to false:
132
+ When a superjob is queued, records for all of its subjobs are created. By default, these records are deleted after the superjob completes. This can be changed by setting the following option to false:
133
133
 
134
134
  ```ruby
135
135
  # config/initializers/superworker.rb
@@ -179,7 +179,7 @@ end
179
179
  MyBatchSuperworker.perform_async([10, 11, 12], [20, 21, 22])
180
180
  ```
181
181
 
182
- The above produces the a sequence equivalent to this (the workers run serially):
182
+ The above produces a sequence equivalent to this (the workers run serially):
183
183
 
184
184
  ```ruby
185
185
  Worker1.new.perform(10, 20)
@@ -210,16 +210,22 @@ If a subjob encounters an exception, the subjobs that depend on it won't run, bu
210
210
 
211
211
  If sidekiq_monitor is being used, the exception will be bubbled up to the superjob, which lets you easily see when your superjobs have failed.
212
212
 
213
- Upgrading to 1.x
214
- ----------------
213
+ Upgrade Notes
214
+ -------------
215
+
216
+ ### Upgrading from 1.0.x to 1.1.x while using Sidekiq Monitor
217
+
218
+ If you're using Sidekiq Monitor, were previously using Sidekiq Superworker 1.0.x, and are upgrading to 1.1.x, you should be aware that the strategy for storing subjob IDs has changed. Before upgrading, you should let all of your superworkers finish, then upgrade, then resume running your superworkers. For superjobs that ran before the upgrade, the relationship between superjobs and subjobs will no longer be shown in some parts of the UI. If you're not using Sidekiq Monitor, you can upgrade without any interruption.
219
+
220
+ ### Upgrading from 0.x to 1.x
215
221
 
216
222
  If you were previously using Sidekiq Superworker 0.x and are upgrading to 1.x, there are some changes to be aware of:
217
223
 
218
- ### Redis replaced ActiveRecord
224
+ #### Redis replaced ActiveRecord
219
225
 
220
226
  ActiveRecord was used as the datastore in 0.x due to application-specific requirements, but Redis is a far better choice for many reasons, especially given that Sidekiq uses Redis. When upgrading to 1.x, you'll need to let all of your superjobs complete, then upgrade to 1.x, then resume running superjobs. You can drop the 'sidekiq_superworker_subjobs' table, if you like.
221
227
 
222
- ### Superworker.define replaced Superworker.create
228
+ #### Superworker.define replaced Superworker.create
223
229
 
224
230
  The name of the `Superworker.create` method caused confusion, as some users would call it multiple times. Since it defines a class, it's been renamed to `Superworker.define`. You'll need to replace it accordingly.
225
231
 
@@ -42,7 +42,7 @@ module Sidekiq
42
42
 
43
43
  def find_by_superjob_jid(jid)
44
44
  keys = Sidekiq.redis do |conn|
45
- conn.keys("#{redis_prefix}:#{jid}:*")
45
+ conn.smembers("#{redis_prefix}:#{jid}:subjob_keys")
46
46
  end
47
47
  keys.collect { |key| find_by_key(key) }
48
48
  end
@@ -57,15 +57,16 @@ module Sidekiq
57
57
 
58
58
  def keys
59
59
  Sidekiq.redis do |conn|
60
- conn.keys("#{redis_prefix}:*")
60
+ keys = conn.keys("#{redis_prefix}:*:subjob_keys")
61
+ keys.collect { |key| conn.smembers(key) }.flatten
61
62
  end
62
63
  end
63
64
 
64
65
  def delete_subjobs_for(superjob_id)
65
66
  Sidekiq.redis do |conn|
66
- key = self.jid(superjob_id, '*')
67
- keys = conn.keys("#{redis_prefix}:#{key}")
67
+ keys = conn.smembers("#{redis_prefix}:#{superjob_id}:subjob_keys")
68
68
  conn.del(keys) if keys.any?
69
+ conn.del("#{redis_prefix}:#{superjob_id}:subjob_keys")
69
70
  end
70
71
  end
71
72
 
@@ -91,7 +92,10 @@ module Sidekiq
91
92
  def initialize(params={})
92
93
  if params.present?
93
94
  params.each do |attribute, value|
94
- self.public_send("#{attribute}=", value)
95
+ public_send("#{attribute}=", value)
96
+ end
97
+ Sidekiq.redis do |conn|
98
+ conn.sadd("#{self.class.redis_prefix}:#{superjob_id}:subjob_keys", "#{self.class.redis_prefix}:#{superjob_id}:#{subjob_id}")
95
99
  end
96
100
  end
97
101
  end
@@ -105,12 +109,12 @@ module Sidekiq
105
109
  end
106
110
 
107
111
  def update_attributes(pairs = {})
108
- pairs.each_pair { |attribute, value| send("#{attribute}=", value) }
112
+ pairs.each_pair { |attribute, value| public_send("#{attribute}=", value) }
109
113
  self.save
110
114
  end
111
115
 
112
116
  def update_attribute(attribute, value)
113
- send("#{attribute.to_s}=", value)
117
+ public_send("#{attribute.to_s}=", value)
114
118
  return false unless self.valid?
115
119
  Sidekiq.redis do |conn|
116
120
  conn.hset(key, attribute.to_s, value.to_json)
@@ -155,7 +159,7 @@ module Sidekiq
155
159
  def to_param
156
160
  param = {}
157
161
  ATTRIBUTES.each do |attribute|
158
- param["#{attribute.to_s}".to_sym] = send(attribute).to_json
162
+ param["#{attribute.to_s}".to_sym] = public_send(attribute).to_json
159
163
  end
160
164
  param
161
165
  end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Superworker
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-superworker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Benner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-20 00:00:00.000000000 Z
11
+ date: 2015-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activemodel
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: appraisal
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.12'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.12'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: Define dependency graphs of Sidekiq jobs
@@ -130,19 +130,18 @@ require_paths:
130
130
  - lib
131
131
  required_ruby_version: !ruby/object:Gem::Requirement
132
132
  requirements:
133
- - - '>='
133
+ - - ">="
134
134
  - !ruby/object:Gem::Version
135
135
  version: '0'
136
136
  required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - '>='
138
+ - - ">="
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  requirements: []
142
142
  rubyforge_project:
143
- rubygems_version: 2.2.2
143
+ rubygems_version: 2.4.4
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Define dependency graphs of Sidekiq jobs
147
147
  test_files: []
148
- has_rdoc: