activejob_dj_overrides 0.1.2 → 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/README.md +5 -1
- data/activejob_dj_overrides.gemspec +1 -1
- data/lib/activejob_dj_overrides.rb +4 -0
- data/lib/activejob_dj_overrides/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd2eace683951768c715e07d381604cd8701f105
|
4
|
+
data.tar.gz: 4982e8bb829ad2521ec14efd3943a3b7cdcf59af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4393bd7f4d96204476ed7e28ce28ba1617150137f6ca6f5e8f7ff7a1f21bed065d30af20eeb3bbefdfcfa1cd436f2f3423d377209de0f03bac44a7815e179a50
|
7
|
+
data.tar.gz: aed9dd1c062a7abd341aaa2ac1dc6a8424ce68242ad0bca3dc61804af1d87243cdfd3713282f15a846962a33df87304eaec36daaa19878e330d15aac1486a1ba
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Per-job Overrides for Active Job's DelayedJobAdapter
|
2
2
|
|
3
|
-
Delayed Job allows you to override various settings on a per-job basis (see https://github.com/collectiveidea/delayed_job#custom-jobs). I really missed this feature when I switched to using Active Job, so I wrote this gem, which allows max_attempts, destroy_failed_jobs?, and max_run_time to be defined within your (active) job - just like Delayed Job. See Usage section below for an example.
|
3
|
+
Delayed Job allows you to override various settings on a per-job basis (see https://github.com/collectiveidea/delayed_job#custom-jobs). I really missed this feature when I switched to using Active Job, so I wrote this gem, which allows max_attempts, destroy_failed_jobs?, reschedule_at, and max_run_time to be defined within your (active) job - just like Delayed Job. See Usage section below for an example.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -41,6 +41,10 @@ class YourJob < ActiveJob::Base
|
|
41
41
|
def max_run_time
|
42
42
|
5 # default is 4.hours
|
43
43
|
end
|
44
|
+
|
45
|
+
def reschedule_at(current_time, attempts)
|
46
|
+
current_time + 5.seconds # default is current_time + (attempts**4) + 5
|
47
|
+
end
|
44
48
|
end
|
45
49
|
```
|
46
50
|
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["ajporterfield@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = 'Adds per-job overrides to the delayed_job adapter for Active Job'
|
13
|
-
spec.description = 'Allows max_attempts, destroy_failed_jobs?, and max_run_time methods to be defined in your jobs to override default settings just like you\'re used to in delayed_job'
|
13
|
+
spec.description = 'Allows max_attempts, destroy_failed_jobs?, reschedule_at, and max_run_time methods to be defined in your jobs to override default settings just like you\'re used to in delayed_job'
|
14
14
|
spec.homepage = 'https://github.com/ajporterfield/activejob_dj_overrides'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -15,6 +15,10 @@ module ActivejobDjOverrides
|
|
15
15
|
job.max_run_time rescue Delayed::Worker.max_run_time
|
16
16
|
end
|
17
17
|
|
18
|
+
def reschedule_at(current_time, attempts)
|
19
|
+
job.reschedule_at(current_time, attempts) rescue (current_time + (attempts**4) + 5)
|
20
|
+
end
|
21
|
+
|
18
22
|
private
|
19
23
|
def job
|
20
24
|
@job ||= ActiveJob::Base.deserialize(job_data)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activejob_dj_overrides
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Porterfield
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,9 +66,9 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description: Allows max_attempts, destroy_failed_jobs?, and max_run_time
|
70
|
-
be defined in your jobs to override default settings just like you're
|
71
|
-
delayed_job
|
69
|
+
description: Allows max_attempts, destroy_failed_jobs?, reschedule_at, and max_run_time
|
70
|
+
methods to be defined in your jobs to override default settings just like you're
|
71
|
+
used to in delayed_job
|
72
72
|
email:
|
73
73
|
- ajporterfield@gmail.com
|
74
74
|
executables: []
|