active_job_store 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -3
- data/lib/active_job_store/version.rb +3 -1
- data/lib/active_job_store.rb +8 -3
- 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: df269c0cadf76b1981c02b87f77ac89c81b4dc13896c5162956942cfe274855f
|
4
|
+
data.tar.gz: 2a864cb0aa3573e77f83d8050cc40ce93988c7100838bce05de73e4db0b99f3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4881d10048838fecb729eb48309aacebd77c4071636f7077fe2e3f2f1f3a1f4a8cce0b90ccad6ae59446790c635880c9ede070b245eb5354b2bb9d8e2dedd02d
|
7
|
+
data.tar.gz: 8245277be9b2e65d7b9479a2f9c9740a3167cca1be20e680530d9dedc9ea6fabb8f6cb597f7a7ecabfb633421ce88362118908faafc10e7f889af2f428d30e49
|
data/README.md
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
# ActiveJob Store
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/active_job_store.svg)](https://badge.fury.io/rb/active_job_store)
|
4
|
+
[![Specs Rails 7.0](https://github.com/blocknotes/active_job_store/actions/workflows/specs_70.yml/badge.svg)](https://github.com/blocknotes/active_job_store/actions/workflows/specs_70.yml)
|
5
|
+
[![Linters](https://github.com/blocknotes/active_job_store/actions/workflows/linters.yml/badge.svg)](https://github.com/blocknotes/active_job_store/actions/workflows/linters.yml)
|
6
|
+
|
3
7
|
Persist job execution information on a support model `ActiveJobStore::Record`.
|
4
8
|
|
5
9
|
It can be useful to:
|
6
10
|
- improve jobs logging capabilities;
|
7
11
|
- query historical data about job executions;
|
8
|
-
- extract job's statistical data
|
12
|
+
- extract job's statistical data;
|
13
|
+
- track a job's state or add custom data to the jobs.
|
14
|
+
|
15
|
+
Support some customizations:
|
16
|
+
- set custom data attributes (via `active_job_store_custom_data` accessor);
|
17
|
+
- format the job result to store (overriding `active_job_store_format_result` method).
|
9
18
|
|
10
19
|
## Installation
|
11
20
|
|
@@ -21,7 +30,7 @@ It can be useful to:
|
|
21
30
|
SomeJob.perform_now(123)
|
22
31
|
SomeJob.perform_later(456)
|
23
32
|
SomeJob.set(wait: 1.minute).perform_later(789)
|
24
|
-
|
33
|
+
|
25
34
|
SomeJob.job_executions.first
|
26
35
|
# => #<ActiveJobStore::Record:0x00000001120f6320
|
27
36
|
# id: 1,
|
@@ -59,7 +68,7 @@ SomeJob.job_executions.where(started_at: 16.minutes.ago...).pluck(:job_id, :resu
|
|
59
68
|
# ["267e087e-cfa7-4c88-8d3b-9d40f912733f", "some_result", Wed, 09 Nov 2022 21:13:18.011484000 UTC +00:00]]
|
60
69
|
```
|
61
70
|
|
62
|
-
Some statistics:
|
71
|
+
Some statistics on completed jobs:
|
63
72
|
|
64
73
|
```rb
|
65
74
|
SomeJob.job_executions.completed.map { |job| { id: job.id, execution_time: job.completed_at - job.started_at, started_at: job.started_at } }
|
data/lib/active_job_store.rb
CHANGED
@@ -28,10 +28,15 @@ module ActiveJobStore
|
|
28
28
|
end
|
29
29
|
store_record.update!(details: job.as_json.except(*IGNORE_ATTRS), state: :started, started_at: Time.current)
|
30
30
|
result = block.call
|
31
|
-
|
32
|
-
store_record.update!(
|
31
|
+
formatted_result = job.active_job_store_format_result(result)
|
32
|
+
store_record.update!(
|
33
|
+
state: :completed,
|
34
|
+
completed_at: Time.current,
|
35
|
+
result: formatted_result,
|
36
|
+
custom_data: active_job_store_custom_data
|
37
|
+
)
|
33
38
|
rescue StandardError => e
|
34
|
-
store_record.update!(state: :error, exception: e.inspect)
|
39
|
+
store_record.update!(state: :error, exception: e.inspect, custom_data: active_job_store_custom_data)
|
35
40
|
raise
|
36
41
|
end
|
37
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_job_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|