delayed_job_chainable_hooks 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +74 -0
- data/.github/CODEOWNERS +1 -0
- data/.gitignore +11 -0
- data/.overcommit.yml +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +171 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/delayed_job_chainable_hooks.gemspec +51 -0
- data/lib/delayed_job_chainable_hooks/plugin.rb +54 -0
- data/lib/delayed_job_chainable_hooks/version.rb +5 -0
- data/lib/delayed_job_chainable_hooks.rb +28 -0
- metadata +264 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a97932ee5b5fb3dc036b02556fb0f10482bf7210706f02afcda7961548e983fe
|
4
|
+
data.tar.gz: 7a8a1abc36b21c8a7672e4207c980482707489bd6971813fcaaadb476b69c6b9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b3c458b2b26b7225d0fb4b2500354591ea33147e029a2c654a6711a6924008b45fcb413f16d79b390cdfc652eda7db3014169260d83988d24d0870310410a3e
|
7
|
+
data.tar.gz: ae1cd335f2df094aea099f470c14b1c37760e9c8179661a88155eee8868730efd7b31c20b3e7a1b1550ae69b891bcf94a9af426fce679dd09ac1d33df91876f4
|
@@ -0,0 +1,74 @@
|
|
1
|
+
workflows:
|
2
|
+
build:
|
3
|
+
jobs:
|
4
|
+
- lint:
|
5
|
+
ruby_version: "2.7.7"
|
6
|
+
- test:
|
7
|
+
matrix:
|
8
|
+
parameters:
|
9
|
+
ruby_version:
|
10
|
+
- "2.7.7"
|
11
|
+
- "3.0.5"
|
12
|
+
- "3.1.3"
|
13
|
+
- "3.2.0"
|
14
|
+
version: 2.1
|
15
|
+
jobs:
|
16
|
+
lint:
|
17
|
+
parameters:
|
18
|
+
ruby_version:
|
19
|
+
type: string
|
20
|
+
docker:
|
21
|
+
- image: salsify/ruby_ci:<< parameters.ruby_version >>
|
22
|
+
working_directory: ~/delayed_job_chainable_hooks
|
23
|
+
steps:
|
24
|
+
- checkout
|
25
|
+
- restore_cache:
|
26
|
+
keys:
|
27
|
+
- v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_chainable_hooks.gemspec" }}-{{ checksum "Gemfile" }}
|
28
|
+
- v1-gems-<< parameters.ruby_version >>-
|
29
|
+
- run:
|
30
|
+
name: Install Gems
|
31
|
+
command: |
|
32
|
+
if ! bundle check --path=vendor/bundle; then
|
33
|
+
bundle install --path=vendor/bundle --jobs=4 --retry=3
|
34
|
+
bundle clean
|
35
|
+
fi
|
36
|
+
- save_cache:
|
37
|
+
key: v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_chainable_hooks.gemspec" }}-{{ checksum "Gemfile" }}
|
38
|
+
paths:
|
39
|
+
- "vendor/bundle"
|
40
|
+
- run:
|
41
|
+
name: Run Rubocop
|
42
|
+
command: bundle exec rubocop --config .rubocop.yml
|
43
|
+
test:
|
44
|
+
parameters:
|
45
|
+
ruby_version:
|
46
|
+
type: string
|
47
|
+
docker:
|
48
|
+
- image: salsify/ruby_ci:<< parameters.ruby_version >>
|
49
|
+
environment:
|
50
|
+
CIRCLE_TEST_REPORTS: "test-results"
|
51
|
+
working_directory: ~/delayed_job_chainable_hooks
|
52
|
+
steps:
|
53
|
+
- checkout
|
54
|
+
- restore_cache:
|
55
|
+
keys:
|
56
|
+
- v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_chainable_hooks.gemspec" }}-{{ checksum "Gemfile" }}
|
57
|
+
- v1-gems-<< parameters.ruby_version >>-
|
58
|
+
- run:
|
59
|
+
name: Install Gems
|
60
|
+
command: |
|
61
|
+
if ! bundle check --path=vendor/bundle; then
|
62
|
+
bundle install --path=vendor/bundle --jobs=4 --retry=3
|
63
|
+
bundle clean
|
64
|
+
fi
|
65
|
+
- save_cache:
|
66
|
+
key: v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_chainable_hooks.gemspec" }}-{{ checksum "Gemfile" }}
|
67
|
+
paths:
|
68
|
+
- "vendor/bundle"
|
69
|
+
- run:
|
70
|
+
name: Run Tests
|
71
|
+
command: |
|
72
|
+
bundle exec rspec --format RspecJunitFormatter --out $CIRCLE_TEST_REPORTS/rspec/junit.xml --format progress spec
|
73
|
+
- store_test_results:
|
74
|
+
path: "test-results"
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @skarger @will89
|
data/.gitignore
ADDED
data/.overcommit.yml
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
salsify_rubocop: conf/rubocop.yml
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.7
|
6
|
+
Exclude:
|
7
|
+
# IntelliJ compile target directory
|
8
|
+
- 'out/**/*'
|
9
|
+
# Others excluded by https://github.com/salsify/salsify_rubocop/blob/master/conf/rubocop_without_rspec.yml
|
10
|
+
- 'bin/**/*'
|
11
|
+
- 'coverage/**/*'
|
12
|
+
- 'log/**/*'
|
13
|
+
- 'vendor/**/*'
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
delayed_job_chainable_hooks
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.2
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
|
6
|
+
|
7
|
+
## Unreleased
|
8
|
+
|
9
|
+
## 3.0.0 - 2023-01-20
|
10
|
+
### Changed
|
11
|
+
- Drop support for Ruby 2.6
|
12
|
+
|
13
|
+
## 2.0.0 - 2021-03-31
|
14
|
+
### Changed
|
15
|
+
- Require Ruby 2.6+
|
16
|
+
|
17
|
+
## 1.0.0 - 2017-09-25
|
18
|
+
- Initial version. Extracted from Salsify's internal platform.
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
|
6
|
+
# override the :github shortcut to be secure by using HTTPS
|
7
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
|
8
|
+
|
9
|
+
# Specify your gem's dependencies in delayed_job_chainable_hooks.gemspec
|
10
|
+
gemspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Salsify, Inc
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
# DelayedJobChainableHooks
|
2
|
+
|
3
|
+
DelayedJob lifecyle hooks that allow multiple definitions across modules or parent/child classes.
|
4
|
+
|
5
|
+
DelayedJob has [built-in *job-level* hook methods](https://github.com/collectiveidea/delayed_job#hooks) that support defining a callback on a given Job class.
|
6
|
+
It also has a plugin system that allows adding lifecycle behavior *globally* to Delayed::Worker.
|
7
|
+
|
8
|
+
What about when you want to share hook methods across job clases but not apply them globally?
|
9
|
+
|
10
|
+
One option is to use modules or job-class inheritance. While this works it has the downside that you might overwrite a hook.
|
11
|
+
If you realize that the method has a previous definition you can call `super` but it is error prone.
|
12
|
+
|
13
|
+
This gem provides an alternative: chainable hook methods. They use different names so that you can use them alongside the existing DelayedJob hooks.
|
14
|
+
|
15
|
+
Inspired by [this blog post](https://www.salsify.com/blog/engineering/delayed-jobs-callbacks-and-hooks-in-rails).
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add this line to your application's Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'delayed_job_chainable_hooks'
|
23
|
+
```
|
24
|
+
|
25
|
+
And then execute:
|
26
|
+
|
27
|
+
$ bundle
|
28
|
+
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
$ gem install delayed_job_chainable_hooks
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
Add the plugin to `Delayed::Worker.plugins`. In Rails you could put this line in `config/initializers/delayed_job_config.rb`:
|
36
|
+
|
37
|
+
```
|
38
|
+
Delayed::Worker.plugins << DelayedJobChainableHooks::Plugin
|
39
|
+
```
|
40
|
+
|
41
|
+
Currently the gem provides the following hooks:
|
42
|
+
|
43
|
+
- `before_job_attempt`
|
44
|
+
- `after_job_attempt_error`
|
45
|
+
- `after_job_failure`
|
46
|
+
- `after_job_success`
|
47
|
+
- `after_job_attempt`
|
48
|
+
|
49
|
+
Pass any of these a block in a module or job superclass. The block will be executed at the appropriate point during the job's lifecycle.
|
50
|
+
Optionally pass do the same in a second module or subclass. Both the first and second blocks will be called during the job's lifecycle.
|
51
|
+
|
52
|
+
### Example
|
53
|
+
|
54
|
+
For a subset of our DelayedJobs we want to provide a polling endpoint. When an API client
|
55
|
+
prompts the application to enqueue one of these jobs, we should return a path that the
|
56
|
+
client can subsequently poll to check on the status of the job and adjust the UI accordingly.
|
57
|
+
|
58
|
+
First we create the module to support that behavior, `ClientVisibleJob`.
|
59
|
+
It includes `DelayedJobChainableHooks`. It maintains job status in
|
60
|
+
an ActiveRecord model named `ClientJobStatus`.
|
61
|
+
|
62
|
+
Note that we define the hooks by passing blocks to the methods provided by this gem,
|
63
|
+
unlike base DelayedJob where you implement the hook methods in the standard Ruby way using `def`.
|
64
|
+
|
65
|
+
```
|
66
|
+
module ClientVisibleJob
|
67
|
+
extend ActiveSupport::Concern
|
68
|
+
include DelayedJobChainableHooks
|
69
|
+
|
70
|
+
included do
|
71
|
+
attr_accessor :client_status_id
|
72
|
+
|
73
|
+
after_job_success do
|
74
|
+
client_status.update!(status: :completed)
|
75
|
+
end
|
76
|
+
|
77
|
+
after_job_failure do
|
78
|
+
client_status.update!(status: :failed)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def initialize(*args)
|
83
|
+
@client_status = ClientJobStatus.create!(status: :running)
|
84
|
+
self.client_status_id = @client_status.id
|
85
|
+
super
|
86
|
+
end
|
87
|
+
|
88
|
+
def client_status
|
89
|
+
@client_status ||= ClientJobStatus.find(client_status_id)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
```
|
93
|
+
|
94
|
+
Now `ClientVisibleJob` can be included in specific job classes. Those classes
|
95
|
+
may define their own versions of the hook methods but the ones defined in
|
96
|
+
`ClientVisibleJob` will still execute.
|
97
|
+
|
98
|
+
```
|
99
|
+
class MakeSouffleJob
|
100
|
+
|
101
|
+
include ClientVisibleJob
|
102
|
+
|
103
|
+
def perform
|
104
|
+
whip_egg_whites
|
105
|
+
mix_egg_whites_into_yokes
|
106
|
+
place_in_baking_dish
|
107
|
+
bake
|
108
|
+
end
|
109
|
+
|
110
|
+
before_job_attempt do
|
111
|
+
Delayed::Worker.logger.info("Let's make a souffle.")
|
112
|
+
end
|
113
|
+
|
114
|
+
after_job_success do
|
115
|
+
Delayed::Worker.logger.info("Souffle has risen!")
|
116
|
+
end
|
117
|
+
|
118
|
+
after_job_failure do
|
119
|
+
Delayed::Worker.logger.warn("Souffle has fallen!")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
```
|
123
|
+
|
124
|
+
Code that enqueues this job, such as a web request handler, can treat `MakeSouffleJob`
|
125
|
+
as a `ClientVisibleJob` and provide a status polling endpoint to clients.
|
126
|
+
|
127
|
+
```
|
128
|
+
def post
|
129
|
+
job = MakeSouffleJob.new
|
130
|
+
Delayed::Job.enqueue(job)
|
131
|
+
|
132
|
+
render status: :accepted, json: { status: "/souffle-status/#{job.client_status_id}" }
|
133
|
+
end
|
134
|
+
```
|
135
|
+
|
136
|
+
Other jobs that we want to make pollable can follow the same pattern.
|
137
|
+
|
138
|
+
|
139
|
+
### Logging
|
140
|
+
|
141
|
+
By default this gem will use DelayedJob's built-in `Delayed::Worker.logger`. If you want this gem to log somewhere else, set it as follows in a Rails initializer or wherever works for you.
|
142
|
+
|
143
|
+
```
|
144
|
+
DelayedJobChainableCallbacks.logger = Logger.new('my-log-file')
|
145
|
+
```
|
146
|
+
|
147
|
+
## Development
|
148
|
+
|
149
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
150
|
+
run `rake spec` to run the tests. You can also run `bin/console` for an
|
151
|
+
interactive prompt that will allow you to experiment.
|
152
|
+
|
153
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
154
|
+
|
155
|
+
### Release (maintainers only)
|
156
|
+
|
157
|
+
To release a new version, update the version number in `version.rb`, and then
|
158
|
+
run `bundle exec rake release`, which will create a git tag for the version,
|
159
|
+
push git commits and tags, and push the `.gem` file to
|
160
|
+
[rubygems.org](https://rubygems.org)
|
161
|
+
.
|
162
|
+
|
163
|
+
## Contributing
|
164
|
+
|
165
|
+
Bug reports and pull requests are welcome on GitHub at
|
166
|
+
https://github.com/salsify/delayed_job_chainable_hooks.
|
167
|
+
|
168
|
+
## License
|
169
|
+
|
170
|
+
The gem is available as open source under the terms of the
|
171
|
+
[MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'delayed_job_chainable_hooks'
|
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,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'delayed_job_chainable_hooks/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'delayed_job_chainable_hooks'
|
9
|
+
spec.version = DelayedJobChainableHooks::VERSION
|
10
|
+
spec.authors = ['Salsify, Inc']
|
11
|
+
spec.email = ['engineering@salsify.com']
|
12
|
+
|
13
|
+
spec.summary = 'Implement DelayedJob hook methods in multiple modules/job classes ' \
|
14
|
+
'without overriding previous definitions.'
|
15
|
+
spec.description = spec.summary
|
16
|
+
spec.homepage = 'https://github.com/salsify/delayed_job_chainable_hooks'
|
17
|
+
|
18
|
+
spec.license = 'MIT'
|
19
|
+
|
20
|
+
|
21
|
+
# Set 'allowed_push_post' to control where this gem can be published.
|
22
|
+
if spec.respond_to?(:metadata)
|
23
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
24
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
25
|
+
|
26
|
+
else
|
27
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
28
|
+
end
|
29
|
+
|
30
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
31
|
+
spec.bindir = 'bin'
|
32
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ['lib']
|
34
|
+
spec.required_ruby_version = '>= 2.7'
|
35
|
+
|
36
|
+
spec.add_dependency 'activesupport', '>= 5.2'
|
37
|
+
spec.add_dependency 'delayed_job', '>= 4.1'
|
38
|
+
spec.add_dependency 'delayed_job_active_record'
|
39
|
+
spec.add_dependency 'hooks'
|
40
|
+
|
41
|
+
spec.add_development_dependency 'activerecord', '>= 5.2'
|
42
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
43
|
+
spec.add_development_dependency 'database_cleaner'
|
44
|
+
spec.add_development_dependency 'overcommit'
|
45
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
46
|
+
spec.add_development_dependency 'rspec', '>= 3.8'
|
47
|
+
spec.add_development_dependency 'rspec_junit_formatter'
|
48
|
+
spec.add_development_dependency 'salsify_rubocop', '~> 1.43.0'
|
49
|
+
spec.add_development_dependency 'simplecov'
|
50
|
+
spec.add_development_dependency 'sqlite3'
|
51
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DelayedJobChainableHooks
|
4
|
+
class Plugin < Delayed::Plugin
|
5
|
+
|
6
|
+
# Set callbacks that are available via the Delayed Job lifecycle mechanism
|
7
|
+
callbacks do |lifecycle|
|
8
|
+
lifecycle.before(:perform) do |_, job|
|
9
|
+
payload = DelayedJobChainableHooks::Plugin.payload_object(job)
|
10
|
+
DelayedJobChainableHooks::Plugin.safe_run_hooks(payload, :before_job_attempt, job)
|
11
|
+
end
|
12
|
+
|
13
|
+
lifecycle.around(:invoke_job) do |job, *args, &block|
|
14
|
+
payload = DelayedJobChainableHooks::Plugin.payload_object(job)
|
15
|
+
begin
|
16
|
+
block.call(job, *args)
|
17
|
+
DelayedJobChainableHooks::Plugin.run_hooks(payload, :after_job_success)
|
18
|
+
rescue StandardError => e
|
19
|
+
DelayedJobChainableHooks::Plugin.run_hooks(payload, :after_job_attempt_error, e)
|
20
|
+
raise e
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
lifecycle.after(:perform) do |_, job|
|
25
|
+
payload = DelayedJobChainableHooks::Plugin.payload_object(job)
|
26
|
+
DelayedJobChainableHooks::Plugin.safe_run_hooks(payload, :after_job_attempt, job)
|
27
|
+
end
|
28
|
+
|
29
|
+
lifecycle.after(:failure) do |_, job|
|
30
|
+
payload = Plugin.payload_object(job)
|
31
|
+
DelayedJobChainableHooks::Plugin.safe_run_hooks(payload, :after_job_failure)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.payload_object(job)
|
36
|
+
payload = job.payload_object
|
37
|
+
if payload.is_a?(Delayed::PerformableMethod)
|
38
|
+
payload.object
|
39
|
+
else
|
40
|
+
payload
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.safe_run_hooks(object, hook_name, *args)
|
45
|
+
run_hooks(object, hook_name, *args)
|
46
|
+
rescue StandardError => e
|
47
|
+
DelayedJobChainableHooks.logger.warn("Failed to run hook #{hook_name} on #{object.class}: #{e.message}")
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.run_hooks(object, hook_name, *args)
|
51
|
+
object.run_hook(hook_name, *args) if object.is_a?(DelayedJobChainableHooks)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'delayed_job'
|
4
|
+
require 'delayed_job_active_record'
|
5
|
+
require 'hooks'
|
6
|
+
require 'active_support'
|
7
|
+
require 'delayed_job_chainable_hooks/version'
|
8
|
+
require 'delayed_job_chainable_hooks/plugin'
|
9
|
+
|
10
|
+
# Top-level gem module
|
11
|
+
module DelayedJobChainableHooks
|
12
|
+
extend ActiveSupport::Concern
|
13
|
+
|
14
|
+
def self.logger
|
15
|
+
@logger ||= Delayed::Worker.logger
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.logger=(logger)
|
19
|
+
@logger = logger
|
20
|
+
end
|
21
|
+
|
22
|
+
included do
|
23
|
+
include Hooks
|
24
|
+
|
25
|
+
define_hooks :before_job_attempt, :after_job_attempt,
|
26
|
+
:after_job_attempt_error, :after_job_failure, :after_job_success
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: delayed_job_chainable_hooks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Salsify, Inc
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: delayed_job
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: delayed_job_active_record
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hooks
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activerecord
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: database_cleaner
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: overcommit
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '13.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '13.0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '3.8'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '3.8'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rspec_junit_formatter
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: salsify_rubocop
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 1.43.0
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 1.43.0
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: simplecov
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: sqlite3
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
description: Implement DelayedJob hook methods in multiple modules/job classes without
|
210
|
+
overriding previous definitions.
|
211
|
+
email:
|
212
|
+
- engineering@salsify.com
|
213
|
+
executables:
|
214
|
+
- console
|
215
|
+
- setup
|
216
|
+
extensions: []
|
217
|
+
extra_rdoc_files: []
|
218
|
+
files:
|
219
|
+
- ".circleci/config.yml"
|
220
|
+
- ".github/CODEOWNERS"
|
221
|
+
- ".gitignore"
|
222
|
+
- ".overcommit.yml"
|
223
|
+
- ".rspec"
|
224
|
+
- ".rubocop.yml"
|
225
|
+
- ".ruby-gemset"
|
226
|
+
- ".ruby-version"
|
227
|
+
- CHANGELOG.md
|
228
|
+
- Gemfile
|
229
|
+
- LICENSE.txt
|
230
|
+
- README.md
|
231
|
+
- Rakefile
|
232
|
+
- bin/console
|
233
|
+
- bin/setup
|
234
|
+
- delayed_job_chainable_hooks.gemspec
|
235
|
+
- lib/delayed_job_chainable_hooks.rb
|
236
|
+
- lib/delayed_job_chainable_hooks/plugin.rb
|
237
|
+
- lib/delayed_job_chainable_hooks/version.rb
|
238
|
+
homepage: https://github.com/salsify/delayed_job_chainable_hooks
|
239
|
+
licenses:
|
240
|
+
- MIT
|
241
|
+
metadata:
|
242
|
+
allowed_push_host: https://rubygems.org
|
243
|
+
rubygems_mfa_required: 'true'
|
244
|
+
post_install_message:
|
245
|
+
rdoc_options: []
|
246
|
+
require_paths:
|
247
|
+
- lib
|
248
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
249
|
+
requirements:
|
250
|
+
- - ">="
|
251
|
+
- !ruby/object:Gem::Version
|
252
|
+
version: '2.7'
|
253
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ">="
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
258
|
+
requirements: []
|
259
|
+
rubygems_version: 3.3.26
|
260
|
+
signing_key:
|
261
|
+
specification_version: 4
|
262
|
+
summary: Implement DelayedJob hook methods in multiple modules/job classes without
|
263
|
+
overriding previous definitions.
|
264
|
+
test_files: []
|