activejob_dj_overrides 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +59 -0
- data/Rakefile +1 -0
- data/activejob_dj_overrides.gemspec +31 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/activejob_dj_overrides/version.rb +3 -0
- data/lib/activejob_dj_overrides.rb +25 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7298f1d65167a33c9ac6f72ee2a8161e1bd2f609
|
4
|
+
data.tar.gz: 0f119bbe59d90d7e6413552ce4766e9be4f4df09
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c239abe92e47e841837ad88599f9db1ade88d7e2871a6e039ad0aa12d544379b4d19af722ae64111b397401a7fb59138ba8d985df5cf94d755c6a36c429c1181
|
7
|
+
data.tar.gz: 5c40ed9a5846bbaf7f93837f37081fb8d7a29f29b6613dc0823aed32a6b4bd0b129bb63a3e35a83386844f104cd7a42008fe9acdd1cf51ce5791d4016d2eb404
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Per-job Overrides for Active Job's DelayedJobAdapter
|
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.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'activejob_dj_overrides'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install activejob_dj_overrides
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
class YourJob < ActiveJob::Base
|
25
|
+
queue_as :default
|
26
|
+
|
27
|
+
def perform(*args)
|
28
|
+
# Do something later
|
29
|
+
# sleep 1.minute # tests max_run_time
|
30
|
+
# nil > 0 # tests max_attempts and destroy_failed_jobs?
|
31
|
+
end
|
32
|
+
|
33
|
+
def max_attempts
|
34
|
+
1 # default is 25
|
35
|
+
end
|
36
|
+
|
37
|
+
def destroy_failed_jobs?
|
38
|
+
false # default is true
|
39
|
+
end
|
40
|
+
|
41
|
+
def max_run_time
|
42
|
+
5 # default is 4.hours
|
43
|
+
end
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
## Development
|
48
|
+
|
49
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
50
|
+
|
51
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
1. Fork it ( https://github.com/[my-github-username]/activejob_dj_overrides/fork )
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
59
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'activejob_dj_overrides/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "activejob_dj_overrides"
|
8
|
+
spec.version = ActivejobDjOverrides::VERSION
|
9
|
+
spec.authors = ["Andrew Porterfield"]
|
10
|
+
spec.email = ["ajporterfield@gmail.com"]
|
11
|
+
|
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'
|
14
|
+
spec.homepage = 'https://github.com/ajporterfield/activejob_dj_overrides'
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
# if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
# else
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
# end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "activejob_dj_overrides"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "activejob_dj_overrides/version"
|
2
|
+
|
3
|
+
module ActivejobDjOverrides
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def max_attempts
|
7
|
+
job.max_attempts rescue Delayed::Worker.max_attempts
|
8
|
+
end
|
9
|
+
|
10
|
+
def destroy_failed_jobs?
|
11
|
+
job.destroy_failed_jobs? rescue Delayed::Worker.destroy_failed_jobs
|
12
|
+
end
|
13
|
+
|
14
|
+
def max_run_time
|
15
|
+
job.max_run_time rescue Delayed::Worker.max_run_time
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def job
|
20
|
+
puts 'job'
|
21
|
+
@job ||= ActiveJob::Base.deserialize(job_data)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper.send(:include, ActivejobDjOverrides)
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activejob_dj_overrides
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Porterfield
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Allows max_attempts, destroy_failed_jobs?, and max_run_time methods to
|
42
|
+
be defined in your jobs to override default settings just like you're used to in
|
43
|
+
delayed_job
|
44
|
+
email:
|
45
|
+
- ajporterfield@gmail.com
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- ".rspec"
|
52
|
+
- ".travis.yml"
|
53
|
+
- Gemfile
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- activejob_dj_overrides.gemspec
|
57
|
+
- bin/console
|
58
|
+
- bin/setup
|
59
|
+
- lib/activejob_dj_overrides.rb
|
60
|
+
- lib/activejob_dj_overrides/version.rb
|
61
|
+
homepage: https://github.com/ajporterfield/activejob_dj_overrides
|
62
|
+
licenses: []
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.4.6
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Adds per-job overrides to the delayed_job adapter for Active Job
|
84
|
+
test_files: []
|