postburner 0.5.0 → 0.6.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: ffbffc2cebbe2e83bfff21178b71d0b205756cd6ef05c6dc30c8029d073c70d7
4
- data.tar.gz: 68136a8de901340817dcd60e0fbd3b6794eb6dea2f8da386af138576dbba6334
3
+ metadata.gz: f0c2a65b18596dafa8809d07924e2274f7adc05ce971fea1b82143c7132f2929
4
+ data.tar.gz: e3000b8fa490aec4fb1c8b49c54fe7ee78613b3e7e3849c2270d7a7dd01adecd
5
5
  SHA512:
6
- metadata.gz: 319ebb136625b266efe9189c8f6114ee7153ad18503b6d38343609a8bcb62dc3ea814b4b22e60f685f90f68957a2c9647ff3c958e26983796fc2c40bb8cb981c
7
- data.tar.gz: 0fb16c1e08994dc7676b1546dc9d492c51243a9bcf8ffa9a2367b0a4274ecd806c322f00b6304a637fbfa20ddb2bc0872bd5ccdb357bba1d518f60f589edbf46
6
+ metadata.gz: 87cb7aec3924346ab43b93f5886aebfb1b138a36b199eb3e10032404a23b07774c287cb96ed8c4889feabde1106aba63d23d6429cead43f3eec8211f257d6baa
7
+ data.tar.gz: 94e32291c4f00db869a630adeea7e44abb92c4938e2314fc5e46ea487b874acc4a74b80771bd8db8944f3a7c98e06101ef90a36f8da5bf72d7fecc82fbd14c3c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.6.0 - 2021-11-01
4
+
5
+ ### Added
6
+ - update exception handling to better show where the error was raised.
7
+ - update logging to match errata format.
8
+ - update documentation.
9
+
3
10
  ## v0.5.0 - 2021-10-27
4
11
 
5
12
  ### Added
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
- self.perform(args)
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
- self.update_columns(
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
- options[:level],
196
- message,
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
- update_columns(
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
@@ -1,3 +1,3 @@
1
1
  module Postburner
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
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.5.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-10-27 00:00:00.000000000 Z
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails