activejob-status 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/activejob-status/status.rb +23 -5
- data/lib/activejob-status/version.rb +1 -1
- data/lib/activejob-status.rb +6 -5
- metadata +3 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caa59f53f6175aea2f38a219adfd4a707fc3fb8460265aeff78adc7b09a494f2
|
4
|
+
data.tar.gz: f8775e045b684ba6cc1215e2e7570ba8e7b4f10ad889d7fb5d78bea44a5b62f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a15529aeaab2bf3e25a5a56fab998e867f9af6fd3f835b788a84f001f9f4be4f974c8e7e2d3d40f8f45b6d764b40984af69a11cc95c9edece1e6e987c8e5dee8
|
7
|
+
data.tar.gz: 48fa3e3ee20a768007b830b5f5019d958594c4ec26ffd8d0bdb8bcd7d0dbdbd8d6da63408df591bda657b5de93bc991f08f84b7b8076cf699ed86385671d72e2
|
@@ -8,7 +8,8 @@ module ActiveJob
|
|
8
8
|
|
9
9
|
def initialize(job, options = {})
|
10
10
|
options = ActiveJob::Status.options.merge(options)
|
11
|
-
@
|
11
|
+
@defaults = options.fetch(:includes, [])
|
12
|
+
@storage = ActiveJob::Status::Storage.new(options.without(:includes))
|
12
13
|
@job = job
|
13
14
|
end
|
14
15
|
|
@@ -21,11 +22,11 @@ module ActiveJob
|
|
21
22
|
end
|
22
23
|
alias_method :to_h, :read
|
23
24
|
|
24
|
-
def update(
|
25
|
-
@job.progress.instance_variable_set(:@progress,
|
26
|
-
@job.progress.instance_variable_set(:@total,
|
25
|
+
def update(payload, options = {})
|
26
|
+
@job.progress.instance_variable_set(:@progress, payload[:progress]) if payload.include?(:progress)
|
27
|
+
@job.progress.instance_variable_set(:@total, payload[:total]) if payload.include?(:total)
|
27
28
|
|
28
|
-
@storage.update(@job,
|
29
|
+
@storage.update(@job, payload, **options)
|
29
30
|
end
|
30
31
|
|
31
32
|
def delete
|
@@ -51,6 +52,23 @@ module ActiveJob
|
|
51
52
|
def status_inquiry
|
52
53
|
status.to_s.inquiry
|
53
54
|
end
|
55
|
+
|
56
|
+
# Update default data
|
57
|
+
|
58
|
+
def update_defaults(status_key)
|
59
|
+
payload = {}
|
60
|
+
payload[:status] = status_key if @defaults.include?(:status)
|
61
|
+
payload[:serialized_job] = @job.serialize if @defaults.include?(:serialized_job)
|
62
|
+
update(payload, force: true)
|
63
|
+
end
|
64
|
+
|
65
|
+
def catch_exception(e)
|
66
|
+
payload = {}
|
67
|
+
payload[:status] = :failed if @defaults.include?(:status)
|
68
|
+
payload[:serialized_job] = @job.serialize if @defaults.include?(:serialized_job)
|
69
|
+
payload[:exception] = {class: e.class.name, message: e.message} if @defaults.include?(:exception)
|
70
|
+
update(payload, force: true)
|
71
|
+
end
|
54
72
|
end
|
55
73
|
end
|
56
74
|
end
|
data/lib/activejob-status.rb
CHANGED
@@ -13,16 +13,17 @@ module ActiveJob
|
|
13
13
|
|
14
14
|
DEFAULT_OPTIONS = {
|
15
15
|
expires_in: 60 * 30,
|
16
|
-
throttle_interval: 0
|
16
|
+
throttle_interval: 0,
|
17
|
+
includes: %i[status]
|
17
18
|
}.freeze
|
18
19
|
|
19
20
|
included do
|
20
|
-
before_enqueue { |job| job.status
|
21
|
-
before_perform { |job| job.status
|
22
|
-
after_perform { |job| job.status
|
21
|
+
before_enqueue { |job| job.status.update_defaults(:queued) }
|
22
|
+
before_perform { |job| job.status.update_defaults(:working) }
|
23
|
+
after_perform { |job| job.status.update_defaults(:completed) }
|
23
24
|
|
24
25
|
rescue_from(Exception) do |e|
|
25
|
-
status
|
26
|
+
status.catch_exception(e)
|
26
27
|
raise e
|
27
28
|
end
|
28
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activejob-status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Savater Sebastien
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -38,118 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '4.2'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '13.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '13.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '3.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: bundler
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.3'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.3'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.20'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '1.20'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rubocop-performance
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '1.11'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '1.11'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rubocop-rspec
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '2.4'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '2.4'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop-rake
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: standard
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: 1.3.0
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: 1.3.0
|
153
41
|
description:
|
154
42
|
email:
|
155
43
|
- savater.sebastien@gmail.com
|
@@ -182,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
70
|
- !ruby/object:Gem::Version
|
183
71
|
version: '0'
|
184
72
|
requirements: []
|
185
|
-
rubygems_version: 3.
|
73
|
+
rubygems_version: 3.3.7
|
186
74
|
signing_key:
|
187
75
|
specification_version: 4
|
188
76
|
summary: Monitor your jobs
|