active_job_metadata 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/active_job_metadata/lifecycle.rb +24 -3
- data/lib/active_job_metadata/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9425ff2e795e089715d220edc61990c26cda412
|
4
|
+
data.tar.gz: cc52260ce46921a85174eea8106034c7405e8490
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5952f81861c721134eeef0693198ed1b83a6fff4f2be3e5f97805a82bba2675214d9d5462cc34ad3ff48275f2a494ee83237dd9c5ff0081f2e450ea92d28e2b1
|
7
|
+
data.tar.gz: f4c96ee100e82d53161b427ef3c9884fbee209557e19dc6965d177b47dbdd7d129c7a02035a2545d848acb339521537bf49a44d94f7253ea1357595b307341fe
|
data/CHANGELOG.md
ADDED
@@ -1,9 +1,21 @@
|
|
1
1
|
# Use Lifecyle to track the current status of your job.
|
2
2
|
#
|
3
|
+
# Jobs travel through the following states:
|
4
|
+
#
|
5
|
+
# ENQUEUED -> RUNNING -> DONE
|
6
|
+
# '-> FAILED
|
7
|
+
#
|
8
|
+
# The current state of the job is available via the
|
9
|
+
# status accessor.
|
10
|
+
#
|
11
|
+
# Note that a job does not have any status until it is enqueued.
|
12
|
+
# You can of course set the status manually if needed.
|
13
|
+
#
|
3
14
|
module ActiveJobMetadata::Lifecycle
|
4
15
|
ENQUEUED = "enqueued"
|
5
16
|
RUNNING = "running"
|
6
17
|
DONE = "done"
|
18
|
+
FAILED = "failed"
|
7
19
|
|
8
20
|
extend ActiveSupport::Concern
|
9
21
|
include ActiveJobMetadata::Metadata
|
@@ -11,9 +23,18 @@ module ActiveJobMetadata::Lifecycle
|
|
11
23
|
included do
|
12
24
|
metadata :status
|
13
25
|
|
14
|
-
after_enqueue
|
15
|
-
|
16
|
-
|
26
|
+
after_enqueue {|job| job.status = ENQUEUED }
|
27
|
+
|
28
|
+
around_perform do |job, block|
|
29
|
+
begin
|
30
|
+
job.status = RUNNING
|
31
|
+
block.call
|
32
|
+
job.status = DONE
|
33
|
+
rescue Exception => ex
|
34
|
+
job.status = FAILED
|
35
|
+
raise ex
|
36
|
+
end
|
37
|
+
end
|
17
38
|
end
|
18
39
|
|
19
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_job_metadata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- adam sanderson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -102,6 +102,7 @@ extra_rdoc_files: []
|
|
102
102
|
files:
|
103
103
|
- ".gitignore"
|
104
104
|
- ".travis.yml"
|
105
|
+
- CHANGELOG.md
|
105
106
|
- Gemfile
|
106
107
|
- README.md
|
107
108
|
- Rakefile
|