postburner 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +11 -0
- data/app/models/postburner/job.rb +32 -12
- data/lib/postburner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0c2a65b18596dafa8809d07924e2274f7adc05ce971fea1b82143c7132f2929
|
4
|
+
data.tar.gz: e3000b8fa490aec4fb1c8b49c54fe7ee78613b3e7e3849c2270d7a7dd01adecd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87cb7aec3924346ab43b93f5886aebfb1b138a36b199eb3e10032404a23b07774c287cb96ed8c4889feabde1106aba63d23d6429cead43f3eec8211f257d6baa
|
7
|
+
data.tar.gz: 94e32291c4f00db869a630adeea7e44abb92c4938e2314fc5e46ea487b874acc4a74b80771bd8db8944f3a7c98e06101ef90a36f8da5bf72d7fecc82fbd14c3c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -47,6 +47,17 @@ RunDonation.create!(args: {donation_id: 123}).queue! delay: 1.hour
|
|
47
47
|
=> {:status=>"INSERTED", :id=>"1141"}
|
48
48
|
```
|
49
49
|
|
50
|
+
### Mailers
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
j = Postburner::Mailer.
|
54
|
+
delivery(UserMailer, :welcome)
|
55
|
+
.with(name: 'Freddy')
|
56
|
+
|
57
|
+
j.queue!
|
58
|
+
=> {:status=>"INSERTED", :id=>"1139"}
|
59
|
+
```
|
60
|
+
|
50
61
|
### [Beaneater](https://github.com/beanstalkd/beaneater) and [beanstalkd](https://raw.githubusercontent.com/beanstalkd/beanstalkd/master/doc/protocol.txt) attributes and methods
|
51
62
|
```ruby
|
52
63
|
# get the beanstalkd job id
|
@@ -100,20 +100,22 @@ module Postburner
|
|
100
100
|
|
101
101
|
self.log!('START')
|
102
102
|
|
103
|
-
|
103
|
+
begin
|
104
|
+
self.perform(args)
|
105
|
+
rescue Exception => exception
|
106
|
+
self.persist_metadata!
|
107
|
+
self.log! '[Postburner] Exception raised during perform prevented completion.'
|
108
|
+
raise exception
|
109
|
+
end
|
104
110
|
|
105
111
|
self.log!('DONE')
|
106
112
|
|
107
113
|
begin
|
108
114
|
now = Time.zone.now
|
109
115
|
_duration = (now - self.processing_at) * 1000 rescue nil
|
110
|
-
|
116
|
+
persist_metadata!(
|
111
117
|
processed_at: now,
|
112
118
|
duration: _duration,
|
113
|
-
errata: self.errata,
|
114
|
-
error_count: self.errata.length,
|
115
|
-
logs: self.logs,
|
116
|
-
log_count: self.logs.length,
|
117
119
|
)
|
118
120
|
rescue Exception => e
|
119
121
|
self.log_exception!(e)
|
@@ -123,7 +125,6 @@ module Postburner
|
|
123
125
|
|
124
126
|
rescue Exception => exception
|
125
127
|
self.log_exception!(exception)
|
126
|
-
self.log! '[Postburner] Exception raised during perform prevented completion.'
|
127
128
|
raise exception
|
128
129
|
end
|
129
130
|
|
@@ -191,12 +192,22 @@ module Postburner
|
|
191
192
|
options[:level] = :error unless LOG_LEVELS.member?(options[:level])
|
192
193
|
|
193
194
|
self.logs << [
|
194
|
-
Time.zone.now,
|
195
|
-
|
196
|
-
|
195
|
+
Time.zone.now, # time
|
196
|
+
{
|
197
|
+
level: options[:level], # level
|
198
|
+
message: message, # message
|
199
|
+
elapsed: self.elapsed_ms, # ms from start
|
200
|
+
}
|
197
201
|
]
|
198
202
|
end
|
199
203
|
|
204
|
+
# ms from attempting_at
|
205
|
+
#
|
206
|
+
def elapsed_ms
|
207
|
+
return unless self.attempting_at
|
208
|
+
(Time.zone.now - self.attempting_at) * 1000
|
209
|
+
end
|
210
|
+
|
200
211
|
def log!(message, options={})
|
201
212
|
self.log(message, options)
|
202
213
|
self.update_column :logs, self.logs
|
@@ -204,6 +215,16 @@ module Postburner
|
|
204
215
|
|
205
216
|
private
|
206
217
|
|
218
|
+
def persist_metadata!(data={})
|
219
|
+
self.update_columns({
|
220
|
+
errata: self.errata,
|
221
|
+
error_count: self.errata.length,
|
222
|
+
logs: self.logs,
|
223
|
+
log_count: self.logs.length,
|
224
|
+
}.merge(data))
|
225
|
+
end
|
226
|
+
|
227
|
+
|
207
228
|
def insert!(options={})
|
208
229
|
response = Backburner::Worker.enqueue(
|
209
230
|
Postburner::Job,
|
@@ -213,10 +234,9 @@ module Postburner
|
|
213
234
|
|
214
235
|
self.log("QUEUED: #{response}")
|
215
236
|
|
216
|
-
|
237
|
+
persist_metadata!(
|
217
238
|
queued_at: Time.zone.now,
|
218
239
|
bkid: response[:id],
|
219
|
-
logs: self.logs,
|
220
240
|
)
|
221
241
|
|
222
242
|
response
|
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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|