fleiss 0.4.4 → 0.4.5

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: ee721d0d8b4ceb6a3308ded176bac0cbb64aafe602bf4aacda952d9440cff486
4
- data.tar.gz: 93f4afd58038d95d24bb75640fc96b613a7eac6a421e18852ade1e25ad9df76b
3
+ metadata.gz: 4a8ecda4ed800fa1d15848bf37c3f7f1a49cba62be614d25eea8725c00baab0d
4
+ data.tar.gz: fade5ca7d61dad9e7a912b99125b1b43159ab61df2c68b02fb8ed21a73382854
5
5
  SHA512:
6
- metadata.gz: '078d55bb3edf9c2419fbbd7c1906195019e50b356301cb2a4570645b5abae563975f6c0ea6d0632ce039f87c7faddb10b9a21170a0486e06011606a4c4039899'
7
- data.tar.gz: cbe4badf9b18b68b9e664ed9bd9a0ec2e1021dfe5ea088ae6a404e6938e325f92fffdb1d24ee8c642b103cdf847272fa85ff2e057c120ee01ce6be8a6d78aed1
6
+ metadata.gz: ee3ee999372b9d214cd7261e115a0a5ceb7b0c3b266dc2924cb6c7f8c888fbd98140fd39a02a75e108af4f541bee564a67cef179ed62e38d4a0ae019f071f182
7
+ data.tar.gz: 70d922d556feeef102242c726c1812f4f4625ee25f19d01087074aa0725b677d0e74e043097f665b9626f3e16bc5a424f5441e8a3e96088e180cabb9d1a99b45
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fleiss (0.4.4)
4
+ fleiss (0.4.5)
5
5
  activejob (>= 6.0)
6
6
  activerecord (>= 6.0)
7
7
  concurrent-ruby
data/README.md CHANGED
@@ -38,6 +38,16 @@ class ExpringJob < ActiveJob::Base
38
38
  end
39
39
  ```
40
40
 
41
+ Allow to subscribe on worker perform method and detect errors
42
+
43
+ ```ruby
44
+ ActiveSupport::Notifications.subscribe('worker_perform.fleiss') do |event|
45
+ break unless event.payload.key?(:exception_object)
46
+
47
+ Raven.capture_exception(event.payload[:exception_object])
48
+ end
49
+ ```
50
+
41
51
  Include the data migration:
42
52
 
43
53
  ```ruby
data/fleiss.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'fleiss'
3
- s.version = '0.4.4'
3
+ s.version = '0.4.5'
4
4
  s.authors = ['Black Square Media Ltd']
5
5
  s.email = ['info@blacksquaremedia.com']
6
6
  s.summary = %(Minimialist background jobs backed by ActiveJob and ActiveRecord.)
data/lib/fleiss/worker.rb CHANGED
@@ -76,7 +76,8 @@ class Fleiss::Worker
76
76
 
77
77
  log(:info) { "Worker #{uuid} execute job ##{job.id} (by thread #{thread_id})" }
78
78
  finished = false
79
- begin
79
+
80
+ ActiveSupport::Notifications.instrument('worker_perform.fleiss', id: job.id, uuid: uuid, thread_id: thread_id) do |payload|
80
81
  ActiveJob::Base.execute job.job_data
81
82
  finished = true
82
83
  rescue StandardError
@@ -84,6 +85,7 @@ class Fleiss::Worker
84
85
  raise
85
86
  ensure
86
87
  finished ? job.finish(owner) : job.reschedule(owner)
88
+ payload[:finished] = finished
87
89
  end
88
90
  end
89
91
 
@@ -16,6 +16,13 @@ RSpec.describe Fleiss::Worker do
16
16
  runner.kill
17
17
  end
18
18
 
19
+ around do |example|
20
+ callback = ->(*args) { notifications.push ActiveSupport::Notifications::Event.new(*args) }
21
+ ActiveSupport::Notifications.subscribed(callback, 'worker_perform.fleiss') do
22
+ example.call
23
+ end
24
+ end
25
+
19
26
  def wait_for
20
27
  100.times do
21
28
  break if yield
@@ -43,5 +50,19 @@ RSpec.describe Fleiss::Worker do
43
50
  TestJob.perform_later('raise')
44
51
  wait_for { Fleiss.backend.not_finished.count.zero? }
45
52
  expect(Fleiss.backend.finished.count).to eq(1)
53
+
54
+ expect(notifications.size).to eq(1)
55
+ expect(notifications.first.payload).to have_key(:id)
56
+ expect(notifications.first.payload).to have_key(:uuid)
57
+ expect(notifications.first.payload).to have_key(:thread_id)
58
+ expect(notifications.first.payload[:finished]).to be_truthy
59
+ expect(notifications.first.payload[:exception_object]).to be_an_instance_of(RuntimeError)
60
+ expect(notifications.first.payload[:exception_object].message).to eq('Failing')
61
+ end
62
+
63
+ private
64
+
65
+ def notifications
66
+ @notifications ||= []
46
67
  end
47
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fleiss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Black Square Media Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-29 00:00:00.000000000 Z
11
+ date: 2021-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob