postburner 0.6.1 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/app/models/postburner/job.rb +43 -28
- data/lib/postburner/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cd364ebe0fbc9c2a58ccf7adaf27fd5d2dc8ea20b237b0588bf0166d9246097
|
4
|
+
data.tar.gz: 6fb7546229e800d08f7ce8cfbc064738c5b674154cf974abd03a8a2fe9256402
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54ce781b47f35920855a4f2491038b81bbe6c658f45fe7b001d2dc3fb2d31a13a87bc67e79a53a3832dfd2b1fb7a0c6cc8e91f686c6264e5c3a52c2513e6cbc9
|
7
|
+
data.tar.gz: d5f865f2a214709e4bcd4da8c04a45840202344ad3e2d9d94dd937f604fd21ca624c18fa284d3ce58e804ce405bb5c2c9bd53921c3706015f492202fe4c1e474
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.6.4 - 2022-05-21
|
4
|
+
|
5
|
+
### Fixed
|
6
|
+
- add rails 7 to gemspec.
|
7
|
+
|
8
|
+
## v0.6.3 - 2021-11-02
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
- fix #remove! to allow removal even if no beanstalkd job present.
|
12
|
+
|
13
|
+
## v0.6.2 - 2021-11-01
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
- add #requeue method.
|
17
|
+
- check if AlreadyProcessed.
|
18
|
+
|
3
19
|
## v0.6.1 - 2021-11-01
|
4
20
|
|
5
21
|
### Updated
|
@@ -31,15 +31,19 @@ module Postburner
|
|
31
31
|
def queue!(options={})
|
32
32
|
return if self.queued_at.present? && self.bkid.present?
|
33
33
|
raise ActiveRecord::RecordInvalid, "Can't queue unless valid." unless self.valid?
|
34
|
+
raise AlreadyProcessed, "Processed at #{self.processed_at}" if self.processed_at
|
35
|
+
|
34
36
|
at = options.delete(:at)
|
37
|
+
now = Time.zone.now
|
35
38
|
|
39
|
+
self.queued_at = now
|
36
40
|
self.run_at = case
|
37
41
|
when at.present?
|
38
42
|
# this is rudimentary, add error handling
|
39
|
-
options[:delay] ||= at.to_i -
|
43
|
+
options[:delay] ||= at.to_i - now.to_i
|
40
44
|
at
|
41
45
|
when options[:delay].present?
|
42
|
-
|
46
|
+
now + options[:delay].seconds
|
43
47
|
end
|
44
48
|
|
45
49
|
@_insert_options = options
|
@@ -47,6 +51,13 @@ module Postburner
|
|
47
51
|
self.save!
|
48
52
|
end
|
49
53
|
|
54
|
+
def requeue!(options={})
|
55
|
+
self.delete!
|
56
|
+
self.bkid, self.queued_at = nil, nil
|
57
|
+
|
58
|
+
self.queue! options
|
59
|
+
end
|
60
|
+
|
50
61
|
def will_insert?
|
51
62
|
@_insert_options.is_a? Hash
|
52
63
|
end
|
@@ -104,7 +115,7 @@ module Postburner
|
|
104
115
|
return
|
105
116
|
end
|
106
117
|
|
107
|
-
self.log!(
|
118
|
+
self.log!("START (bkid #{self.bkid})")
|
108
119
|
|
109
120
|
begin
|
110
121
|
self.perform(args)
|
@@ -114,7 +125,7 @@ module Postburner
|
|
114
125
|
raise exception
|
115
126
|
end
|
116
127
|
|
117
|
-
self.log!(
|
128
|
+
self.log!("DONE (bkid #{self.bkid})")
|
118
129
|
|
119
130
|
begin
|
120
131
|
now = Time.zone.now
|
@@ -155,12 +166,9 @@ module Postburner
|
|
155
166
|
end
|
156
167
|
|
157
168
|
def remove!
|
158
|
-
if self.
|
159
|
-
|
160
|
-
|
161
|
-
else
|
162
|
-
false
|
163
|
-
end
|
169
|
+
return if self.removed_at
|
170
|
+
self.delete!
|
171
|
+
self.update_column(:removed_at, Time.zone.now)
|
164
172
|
end
|
165
173
|
|
166
174
|
def beanstalk_job
|
@@ -181,6 +189,7 @@ module Postburner
|
|
181
189
|
self.errata << [
|
182
190
|
Time.zone.now,
|
183
191
|
{
|
192
|
+
bkid: self.bkid,
|
184
193
|
class: exception.class,
|
185
194
|
message: exception.message,
|
186
195
|
backtrace: exception.backtrace,
|
@@ -200,9 +209,10 @@ module Postburner
|
|
200
209
|
self.logs << [
|
201
210
|
Time.zone.now, # time
|
202
211
|
{
|
203
|
-
|
204
|
-
|
205
|
-
|
212
|
+
bkid: self.bkid,
|
213
|
+
level: options[:level], # level
|
214
|
+
message: message, # message
|
215
|
+
elapsed: self.elapsed_ms, # ms from start
|
206
216
|
}
|
207
217
|
]
|
208
218
|
end
|
@@ -219,6 +229,12 @@ module Postburner
|
|
219
229
|
self.update_column :logs, self.logs
|
220
230
|
end
|
221
231
|
|
232
|
+
def intended_at
|
233
|
+
self.run_at ? self.run_at : self.queued_at
|
234
|
+
end
|
235
|
+
|
236
|
+
class AlreadyProcessed < StandardError; end
|
237
|
+
|
222
238
|
private
|
223
239
|
|
224
240
|
def persist_metadata!(data={})
|
@@ -236,19 +252,22 @@ module Postburner
|
|
236
252
|
end
|
237
253
|
|
238
254
|
def insert!(options={})
|
239
|
-
response =
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
255
|
+
response = nil
|
256
|
+
|
257
|
+
Job.transaction do
|
258
|
+
response = Backburner::Worker.enqueue(
|
259
|
+
Postburner::Job,
|
260
|
+
self.id,
|
261
|
+
options
|
262
|
+
)
|
263
|
+
|
264
|
+
persist_metadata!(
|
265
|
+
bkid: response[:id],
|
266
|
+
)
|
267
|
+
end
|
244
268
|
|
245
269
|
self.log("QUEUED: #{response}")
|
246
270
|
|
247
|
-
persist_metadata!(
|
248
|
-
queued_at: Time.zone.now,
|
249
|
-
bkid: response[:id],
|
250
|
-
)
|
251
|
-
|
252
271
|
response
|
253
272
|
end
|
254
273
|
|
@@ -256,14 +275,10 @@ module Postburner
|
|
256
275
|
now = Time.zone.now
|
257
276
|
self.attempts << now
|
258
277
|
self.attempting_at ||= now
|
259
|
-
self.lag ||= (self.attempting_at - self.intended_at) * 1000
|
278
|
+
self.lag ||= (self.attempting_at - self.intended_at) * 1000 rescue nil
|
260
279
|
now
|
261
280
|
end
|
262
281
|
|
263
|
-
def intended_at
|
264
|
-
self.run_at ? self.run_at : self.queued_at
|
265
|
-
end
|
266
|
-
|
267
282
|
def ensure_sid!
|
268
283
|
self.sid ||= SecureRandom.uuid
|
269
284
|
end
|
data/lib/postburner/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postburner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -20,6 +20,9 @@ dependencies:
|
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 6.1.3.1
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 7.0.3
|
23
26
|
type: :runtime
|
24
27
|
prerelease: false
|
25
28
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,6 +33,9 @@ dependencies:
|
|
30
33
|
- - ">="
|
31
34
|
- !ruby/object:Gem::Version
|
32
35
|
version: 6.1.3.1
|
36
|
+
- - "~>"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 7.0.3
|
33
39
|
- !ruby/object:Gem::Dependency
|
34
40
|
name: backburner
|
35
41
|
requirement: !ruby/object:Gem::Requirement
|