batch_processor 0.2.3 → 0.2.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f0faec9d505307050df1903ac8804fe7978a6b02fb6244955a1e421775002a
|
4
|
+
data.tar.gz: 326e449ba11aedb79606c2b47aa232b4205724a6822cdbb709b65f3b8177674f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e0201cbb2edb12428adb676f2b19177a83153de3612372f8d80755bd3278ecf222ab44107835c2d16c6629be6109f2685f5bc4fdc7364fa04ba4d9187979109
|
7
|
+
data.tar.gz: 5c97dae7e460fc3e1e19216befee5b1e09a1d91a540150ce232722898fda74b217c72023a7534e5e54e2d51031a3a9bc1c8ada21d88f498de499ff6f9a0b927b
|
@@ -33,12 +33,8 @@ module BatchProcessor
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def batch_callbacks(*events)
|
36
|
-
|
37
|
-
|
38
|
-
define_callbacks_with_handler(*batch_events)
|
39
|
-
|
40
|
-
batch_events.each do |batch_event|
|
41
|
-
set_callback batch_event, :around, ->(_, block) { surveil(batch_event) { block.call } }
|
36
|
+
define_callbacks_for(*events, :batch).each do |batch_event|
|
37
|
+
set_callback batch_event, :around, ->(_, block) { surveil(batch_event, batch_id: batch_id) { block.call } }
|
42
38
|
end
|
43
39
|
end
|
44
40
|
end
|
@@ -42,6 +42,14 @@ module BatchProcessor
|
|
42
42
|
|
43
43
|
batch_class.new(batch_id: batch_id)
|
44
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def define_callbacks_for(*events, type)
|
49
|
+
callbacks = events.map { |event| "#{type}_#{event}".to_sym }
|
50
|
+
define_callbacks_with_handler(*callbacks)
|
51
|
+
callbacks
|
52
|
+
end
|
45
53
|
end
|
46
54
|
end
|
47
55
|
end
|
@@ -10,12 +10,8 @@ module BatchProcessor
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def job_callbacks(*events)
|
13
|
-
|
14
|
-
|
15
|
-
define_callbacks_with_handler(*job_events)
|
16
|
-
|
17
|
-
job_events.each do |job_event|
|
18
|
-
set_callback job_event, :around, ->(_, block) { surveil(job_event) { block.call } }
|
13
|
+
define_callbacks_for(*events, :job).each do |job_event|
|
14
|
+
set_callback job_event, :around, ->(_, block) { surveil(job_event, batch_id: batch_id) { block.call } }
|
19
15
|
end
|
20
16
|
end
|
21
17
|
end
|
@@ -5,6 +5,8 @@ module BatchProcessor
|
|
5
5
|
class BatchJob < ActiveJob::Base
|
6
6
|
attr_accessor :batch_id
|
7
7
|
|
8
|
+
include Technologic
|
9
|
+
|
8
10
|
class BatchAbortedError < StandardError; end
|
9
11
|
|
10
12
|
after_enqueue(if: :batch_job?) do |job|
|
@@ -26,7 +28,10 @@ module BatchProcessor
|
|
26
28
|
def rescue_with_handler(exception)
|
27
29
|
batch.job_canceled and return exception if exception.is_a?(BatchAbortedError)
|
28
30
|
|
29
|
-
|
31
|
+
if batch_job?
|
32
|
+
error :batch_job_failed, exception: exception, job_id: job_id
|
33
|
+
batch.job_failure
|
34
|
+
end
|
30
35
|
|
31
36
|
super
|
32
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: batch_processor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Garside
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.14.2
|
62
62
|
- - "<"
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '1.0'
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 0.
|
71
|
+
version: 0.14.2
|
72
72
|
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '1.0'
|