activejob_dj_overrides 0.1.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bd69f662656348febf4926662d831e5e27edc70
4
- data.tar.gz: 4b6344befdad1e3f3018267ed8db3a279e20ad3b
3
+ metadata.gz: dd2eace683951768c715e07d381604cd8701f105
4
+ data.tar.gz: 4982e8bb829ad2521ec14efd3943a3b7cdcf59af
5
5
  SHA512:
6
- metadata.gz: f21fd0679c97086720cc5df788dbbe00dd9eae2de69b3e221533c7dce1a1a69c6194b034c8d96d8423063f90726f48e4fb7842acd9b01831a5897970fc17aeaa
7
- data.tar.gz: fb172d1dacf441a3d898c606b896411e42948e543053ed4eb9e41e28201e6fac9cdc7a167ff54504ce1155b63d1842f0db7305d934e03b462727e52926ee250b
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)
@@ -1,3 +1,3 @@
1
1
  module ActivejobDjOverrides
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.2
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-02 00:00:00.000000000 Z
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 methods to
70
- be defined in your jobs to override default settings just like you're used to in
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: []