recurring_active_job 0.3.0 → 0.4.0
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 +4 -4
- data/README.md +28 -4
- data/lib/recurring_active_job/base.rb +13 -9
- data/lib/recurring_active_job/version.rb +1 -1
- 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: 3fae517957eb8fac2b6eb06280371965354866c1d848fe72f728a6ced95bc69f
|
4
|
+
data.tar.gz: 6f72d60ec0196a6c0e98fc9b891f7461e4107afaf3a84139c2ed97f2f7a1a3f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1799830197e836e0d2e6e734fe2a21cb4b785dbbee1f5e468d29503a9a9e3c8f71b5c9b6972f84ac2f2a32727530e1c267c0822f7a3272973864a834e0d4f64b
|
7
|
+
data.tar.gz: b33e9b50033f2d1be5a79cf4c75be5c3744b33d500558eb9d545f0653187111003a3e244d0c5191f1432d1d40b61a8b4071e3de436b116fa70f2e7ddffbaea95
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#### Adapter agnostic ActiveJob scheduler based on time spent between executions.
|
4
4
|
|
5
5
|
<!--- Version informartion -->
|
6
|
-
*You are viewing the README of version [v0.
|
6
|
+
*You are viewing the README of version [v0.4.0[0m](https://github.com/thisismydesign/recurring_active_job/releases/tag/v0.4.0[0m). You can find other releases [here](https://github.com/thisismydesign/recurring_active_job/releases).*
|
7
7
|
<!--- Version informartion end -->
|
8
8
|
|
9
9
|
| Branch | Status |
|
@@ -107,13 +107,11 @@ Add a shared context to be included when testing Recurring jobs:
|
|
107
107
|
`spec/support/shared_context_for_recurring_active_job.rb`
|
108
108
|
```ruby
|
109
109
|
RSpec.shared_context "recurring active job" do
|
110
|
-
let(:recurring_active_job) {
|
110
|
+
let(:recurring_active_job) { create(:recurring_active_job) }
|
111
111
|
let(:recurring_active_job_params) { { recurring_active_job_id: recurring_active_job.id } }
|
112
112
|
|
113
113
|
before do
|
114
114
|
allow(RecurringActiveJob::Model).to receive(:find).and_return(recurring_active_job)
|
115
|
-
allow(recurring_active_job).to receive(:save!)
|
116
|
-
allow(recurring_active_job).to receive(:destroy!)
|
117
115
|
end
|
118
116
|
end
|
119
117
|
```
|
@@ -127,6 +125,32 @@ RSpec.describe MyJob do
|
|
127
125
|
end
|
128
126
|
```
|
129
127
|
|
128
|
+
### Custom error handling
|
129
|
+
|
130
|
+
`RecurringActiveJob` defines the following generic error handling which is required for some features (but raises the original error at the end):
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
rescue_from(StandardError) do |e|
|
134
|
+
handle_exception(e)
|
135
|
+
end
|
136
|
+
```
|
137
|
+
|
138
|
+
To define your own error handling but keep those features working you can redefine `handle_exception` like this:
|
139
|
+
|
140
|
+
```ruby
|
141
|
+
rescue_from(StandardError) do |e|
|
142
|
+
handle_exception(e)
|
143
|
+
end
|
144
|
+
|
145
|
+
# ...
|
146
|
+
|
147
|
+
def handle_exception(e)
|
148
|
+
super rescue StandardError
|
149
|
+
|
150
|
+
# ...
|
151
|
+
end
|
152
|
+
```
|
153
|
+
|
130
154
|
## Feedback
|
131
155
|
|
132
156
|
Feedback is appreciated.
|
@@ -6,14 +6,8 @@ module RecurringActiveJob
|
|
6
6
|
attr_accessor :logger
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
if ActiveJob.gem_version < Gem::Version.new("5.2.0")
|
12
|
-
recurring_active_job.update!(last_error: e, last_error_details: e)
|
13
|
-
else
|
14
|
-
recurring_active_job.update!(last_error: "#{e.class}: #{e.message}", last_error_details: ruby_style_error(e))
|
15
|
-
end
|
16
|
-
raise e
|
9
|
+
rescue_from(StandardError) do |e|
|
10
|
+
handle_exception(e)
|
17
11
|
end
|
18
12
|
|
19
13
|
before_enqueue do |job|
|
@@ -76,7 +70,17 @@ module RecurringActiveJob
|
|
76
70
|
self.class.logger
|
77
71
|
end
|
78
72
|
|
79
|
-
def
|
73
|
+
def handle_exception(e)
|
74
|
+
recurring_active_job = RecurringActiveJob::Model.find(arguments.first&.dig(:recurring_active_job_id))
|
75
|
+
if ActiveJob.gem_version < Gem::Version.new("5.2.0")
|
76
|
+
recurring_active_job.update!(last_error: e, last_error_details: e)
|
77
|
+
else
|
78
|
+
recurring_active_job.update!(last_error: "#{e.class}: #{e.message}", last_error_details: ruby_style_error(e))
|
79
|
+
end
|
80
|
+
raise e
|
81
|
+
end
|
82
|
+
|
83
|
+
def ruby_style_error(e)
|
80
84
|
e.backtrace.join("\n\t")
|
81
85
|
.sub("\n\t", ": #{e}#{e.class ? " (#{e.class})" : ''}\n\t")
|
82
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recurring_active_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thisismydesign
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|