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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -0
- data/fleiss.gemspec +1 -1
- data/lib/fleiss/worker.rb +3 -1
- data/spec/fleiss/worker_spec.rb +21 -0
- 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: 4a8ecda4ed800fa1d15848bf37c3f7f1a49cba62be614d25eea8725c00baab0d
|
4
|
+
data.tar.gz: fade5ca7d61dad9e7a912b99125b1b43159ab61df2c68b02fb8ed21a73382854
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee3ee999372b9d214cd7261e115a0a5ceb7b0c3b266dc2924cb6c7f8c888fbd98140fd39a02a75e108af4f541bee564a67cef179ed62e38d4a0ae019f071f182
|
7
|
+
data.tar.gz: 70d922d556feeef102242c726c1812f4f4625ee25f19d01087074aa0725b677d0e74e043097f665b9626f3e16bc5a424f5441e8a3e96088e180cabb9d1a99b45
|
data/Gemfile.lock
CHANGED
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
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
|
-
|
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
|
|
data/spec/fleiss/worker_spec.rb
CHANGED
@@ -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
|
+
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-
|
11
|
+
date: 2021-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|