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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 843028f1e40916f667c6bae2fa228919eb0ed5d3
4
- data.tar.gz: 068b6ec80c5f3560a907d3fa609fa4b6408482a5
3
+ metadata.gz: f9425ff2e795e089715d220edc61990c26cda412
4
+ data.tar.gz: cc52260ce46921a85174eea8106034c7405e8490
5
5
  SHA512:
6
- metadata.gz: 2fe763b81691b7fa827e4dd41b2a37185a13d65205f4b9a03057d789600780f0925a50f21adf1004afce8b41071c1304c0e60284332e6f817cdeac6c9cc9a416
7
- data.tar.gz: 25ef63615d7e34c1b91bca5d5baeb37e792ad729d4ae7a3275f7b29770d680bc84d10a5408c377c05a4a7a0ebe9ea6198eaa2c0393d55878056295f94ef1756e
6
+ metadata.gz: 5952f81861c721134eeef0693198ed1b83a6fff4f2be3e5f97805a82bba2675214d9d5462cc34ad3ff48275f2a494ee83237dd9c5ff0081f2e450ea92d28e2b1
7
+ data.tar.gz: f4c96ee100e82d53161b427ef3c9884fbee209557e19dc6965d177b47dbdd7d129c7a02035a2545d848acb339521537bf49a44d94f7253ea1357595b307341fe
@@ -0,0 +1,13 @@
1
+ Change Log
2
+ ==========
3
+
4
+
5
+ 0.2.0
6
+ -----
7
+
8
+ - When a job encounters an error, status now reports `failed`.
9
+
10
+ 0.1.0
11
+ -----
12
+
13
+ - Initial release. Everything is amazing.
@@ -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 { self.status = "enqueued" }
15
- before_perform { self.status = "running" }
16
- after_perform { self.status = "done" }
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
@@ -1,3 +1,3 @@
1
1
  module ActiveJobMetadata
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  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.1.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-09-20 00:00:00.000000000 Z
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