simplekiq 0.1.0 → 1.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 +4 -4
- data/.circleci/config.yml +7 -73
- data/CHANGELOG.md +16 -0
- data/CONTRIBUTORS.md +4 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +63 -38
- data/README.md +11 -0
- data/lib/simplekiq/batch_tracker_job.rb +1 -1
- data/lib/simplekiq/batching_job.rb +41 -17
- data/lib/simplekiq/orchestration_executor.rb +1 -6
- data/lib/simplekiq/orchestration_job.rb +2 -1
- data/lib/simplekiq/version.rb +1 -1
- data/lib/simplekiq.rb +0 -7
- data/simplekiq.gemspec +2 -2
- data/tasks/ci.rake +1 -1
- metadata +21 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69e0bcbcf55efac94c5089a8a781184585a72e73ca6ca348359435b116a6fdf1
|
|
4
|
+
data.tar.gz: 8f4e9ffab0ecf5d8794f0c0bfdf9fc5a01f13109ddf67f6b43b9886670148032
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: adebf247df4237916eeb104675cf8d819cfed1b546312b7bb94ae0177c927339d702a035445274ba652657a18d6d1a5366daef5fd70e8cbfec06c0b58d9d8d9b
|
|
7
|
+
data.tar.gz: f6bf6a6a79bb6c14e2fa7cadd285f96b0fc457f26065e464d25b5772ac4e43ee6a7034de5983a34d730a144e488ae9125280903a35241b3ecd073f517bac1a25
|
data/.circleci/config.yml
CHANGED
|
@@ -1,44 +1,17 @@
|
|
|
1
1
|
version: 2.1
|
|
2
2
|
|
|
3
|
-
orbs:
|
|
4
|
-
gem: doximity/gem-publisher@0
|
|
5
|
-
|
|
6
3
|
executors:
|
|
7
4
|
ruby:
|
|
8
5
|
resource_class: small
|
|
9
6
|
docker:
|
|
10
|
-
- image: cimg/ruby:
|
|
11
|
-
environment:
|
|
12
|
-
BUNDLE_VERSION: "~> 2.1.4"
|
|
7
|
+
- image: cimg/ruby:3.3
|
|
13
8
|
ruby-with-redis:
|
|
14
9
|
resource_class: small
|
|
15
10
|
docker:
|
|
16
|
-
- image: cimg/ruby:
|
|
17
|
-
|
|
18
|
-
BUNDLE_VERSION: "~> 2.1.4"
|
|
19
|
-
- image: redis:4-alpine
|
|
11
|
+
- image: cimg/ruby:3.3
|
|
12
|
+
- image: redis:6.2
|
|
20
13
|
command: redis-server
|
|
21
14
|
|
|
22
|
-
# yaml anchor filters
|
|
23
|
-
always_run: &always_run
|
|
24
|
-
filters:
|
|
25
|
-
branches:
|
|
26
|
-
only: /.*/
|
|
27
|
-
tags:
|
|
28
|
-
only: /^v.*/
|
|
29
|
-
pr_only: &pr_only
|
|
30
|
-
filters:
|
|
31
|
-
branches:
|
|
32
|
-
ignore: master
|
|
33
|
-
tags:
|
|
34
|
-
ignore: /.*/
|
|
35
|
-
version_tags_only: &version_tags_only
|
|
36
|
-
filters:
|
|
37
|
-
branches:
|
|
38
|
-
ignore: /.*/
|
|
39
|
-
tags:
|
|
40
|
-
only: /^v.*/
|
|
41
|
-
|
|
42
15
|
jobs:
|
|
43
16
|
build:
|
|
44
17
|
executor: ruby-with-redis
|
|
@@ -48,18 +21,11 @@ jobs:
|
|
|
48
21
|
name: Install Bundler specific version
|
|
49
22
|
command: |
|
|
50
23
|
gem install bundler --version "${BUNDLE_VERSION}" --force
|
|
51
|
-
- restore_cache:
|
|
52
|
-
keys:
|
|
53
|
-
- v4-bundle-{{ checksum "Gemfile.lock" }}-
|
|
54
24
|
- run:
|
|
55
25
|
name: Install Ruby Dependencies
|
|
56
26
|
command: |
|
|
57
27
|
bundle config set --local path 'vendor/bundle'
|
|
58
28
|
bundle install --jobs=4 --retry=3
|
|
59
|
-
- save_cache:
|
|
60
|
-
key: v4-bundle-{{ checksum "Gemfile.lock" }}-
|
|
61
|
-
paths:
|
|
62
|
-
- vendor/bundle
|
|
63
29
|
- run:
|
|
64
30
|
name: Run Tests
|
|
65
31
|
command: bundle exec rake ci:specs
|
|
@@ -75,41 +41,9 @@ jobs:
|
|
|
75
41
|
- vendor/bundle
|
|
76
42
|
|
|
77
43
|
workflows:
|
|
78
|
-
|
|
79
44
|
main:
|
|
80
45
|
jobs:
|
|
81
|
-
- build:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<<: *always_run
|
|
86
|
-
context: sidekiq-enterprise
|
|
87
|
-
executor: ruby
|
|
88
|
-
name: gem-build
|
|
89
|
-
vendor-cache: false
|
|
90
|
-
cache-salt: simplekiq-v2
|
|
91
|
-
requires:
|
|
92
|
-
- build
|
|
93
|
-
- pre-release-approval:
|
|
94
|
-
<<: *pr_only
|
|
95
|
-
type: approval
|
|
96
|
-
requires:
|
|
97
|
-
- gem-build
|
|
98
|
-
- gem/publish:
|
|
99
|
-
<<: *pr_only
|
|
100
|
-
executor: ruby
|
|
101
|
-
name: gem-publish-pre
|
|
102
|
-
to_rubygems: true
|
|
103
|
-
pre_release: true
|
|
104
|
-
requires:
|
|
105
|
-
- pre-release-approval
|
|
106
|
-
context: artifact_publishing
|
|
107
|
-
- gem/publish:
|
|
108
|
-
<<: *version_tags_only
|
|
109
|
-
name: gem-publish-final
|
|
110
|
-
executor: ruby
|
|
111
|
-
to_rubygems: true
|
|
112
|
-
pre_release: false
|
|
113
|
-
requires:
|
|
114
|
-
- gem-build
|
|
115
|
-
context: artifact_publishing
|
|
46
|
+
- build:
|
|
47
|
+
context:
|
|
48
|
+
- sidekiq-enterprise
|
|
49
|
+
- nexus_readonly
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.1.0]
|
|
8
|
+
* Added `batch_inherits_from_superclass!` to `Simplekiq::BatchingJob`. It is
|
|
9
|
+
**opt-in**: when called in a job class, the generated batch class
|
|
10
|
+
(`<Job>::SimplekiqBatch`) inherits from the including job's own superclass
|
|
11
|
+
(e.g. `ApplicationJob`) instead of `Simplekiq::BaseBatch`, so it picks up
|
|
12
|
+
whatever that superclass provides (sidekiq options defaults, logging hooks,
|
|
13
|
+
kill switches, etc.). Explicit `batch_sidekiq_options` still take precedence.
|
|
14
|
+
Jobs that don't call it are unchanged. The including job's *own* per-class
|
|
15
|
+
`sidekiq_options` are not inherited, since the batch class is a sibling of
|
|
16
|
+
the job, not a subclass of it. Works whether the superclass includes
|
|
17
|
+
`Sidekiq::Job` directly or indirectly via a shared module.
|
|
18
|
+
|
|
19
|
+
## [1.0.0]
|
|
20
|
+
* Only support Sidekiq 7.1 and Sidekiq 8 (dropped support for older versions)
|
|
21
|
+
[#42](https://github.com/doximity/simplekiq/pull/42)
|
|
22
|
+
|
|
7
23
|
## [0.1.0] (pre-release for 1.0)
|
|
8
24
|
* Fix typo in CONTRIBUTORS
|
|
9
25
|
[#5](https://github.com/doximity/simplekiq/pull/5)
|
data/CONTRIBUTORS.md
CHANGED
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
### Tiffany Troha (Doximity)
|
|
23
23
|
* Added support for specifying `sidekiq_options` for the child job in `Simplekiq::BatchingJob`
|
|
24
24
|
|
|
25
|
+
### Lucas Lazzaris (Doximity)
|
|
26
|
+
* Added support for sidekiq 7.x
|
|
27
|
+
* Allowed `Simplekiq::BatchingJob` to be used as a mixin instead of a superclass, allowing it to be used with other job classes that already inherit from a different superclass (e.g., `ApplicationJob` in Rails)
|
|
28
|
+
|
|
25
29
|
### [Daniel Pepper](https://github.com/dpep)
|
|
26
30
|
* On request, graciously took down his unused `simplekiq` placeholder from rubygems so we could continue using the name :raised_hands:
|
|
27
31
|
|
data/Gemfile
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
source "https://rubygems.org"
|
|
2
2
|
|
|
3
|
-
source "https://
|
|
4
|
-
gem "sidekiq-pro", "
|
|
3
|
+
source "https://artifacts.dox.support/repository/gems" do
|
|
4
|
+
gem "sidekiq-pro", "7.3.6"
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
gem "sidekiq", "
|
|
7
|
+
gem "sidekiq", "7.3.7"
|
|
8
8
|
|
|
9
9
|
# Specify your gem's dependencies in simplekiq.gemspec
|
|
10
10
|
gemspec
|
data/Gemfile.lock
CHANGED
|
@@ -1,31 +1,44 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
simplekiq (
|
|
5
|
-
sidekiq (>=
|
|
6
|
-
sidekiq-pro (
|
|
4
|
+
simplekiq (1.1.0)
|
|
5
|
+
sidekiq (>= 7.1, < 9.0)
|
|
6
|
+
sidekiq-pro (>= 7.1, < 9.0)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://artifacts.dox.support/repository/gems/
|
|
10
|
+
specs:
|
|
11
|
+
json (2.16.0)
|
|
12
|
+
language_server-protocol (3.17.0.5)
|
|
13
|
+
lint_roller (1.1.0)
|
|
14
|
+
prism (1.6.0)
|
|
15
|
+
racc (1.8.1)
|
|
16
|
+
sidekiq-pro (7.3.6)
|
|
17
|
+
sidekiq (>= 7.3.7, < 8)
|
|
18
|
+
unicode-emoji (4.1.0)
|
|
7
19
|
|
|
8
20
|
GEM
|
|
9
21
|
remote: https://rubygems.org/
|
|
10
|
-
remote: https://enterprise.contribsys.com/
|
|
11
22
|
specs:
|
|
12
|
-
ast (2.4.
|
|
23
|
+
ast (2.4.3)
|
|
13
24
|
coderay (1.1.3)
|
|
14
|
-
connection_pool (2.
|
|
25
|
+
connection_pool (2.5.4)
|
|
15
26
|
diff-lcs (1.5.0)
|
|
27
|
+
logger (1.7.0)
|
|
16
28
|
method_source (1.0.0)
|
|
17
|
-
parallel (1.
|
|
18
|
-
parser (3.
|
|
29
|
+
parallel (1.27.0)
|
|
30
|
+
parser (3.3.10.0)
|
|
19
31
|
ast (~> 2.4.1)
|
|
32
|
+
racc
|
|
20
33
|
pry (0.14.1)
|
|
21
34
|
coderay (~> 1.1)
|
|
22
35
|
method_source (~> 1.0)
|
|
23
|
-
rack (
|
|
36
|
+
rack (3.2.4)
|
|
24
37
|
rainbow (3.1.1)
|
|
25
38
|
rake (12.3.3)
|
|
26
|
-
redis (
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
redis-client (0.26.1)
|
|
40
|
+
connection_pool
|
|
41
|
+
regexp_parser (2.11.3)
|
|
29
42
|
rspec (3.11.0)
|
|
30
43
|
rspec-core (~> 3.11.0)
|
|
31
44
|
rspec-expectations (~> 3.11.0)
|
|
@@ -41,32 +54,44 @@ GEM
|
|
|
41
54
|
rspec-support (3.11.0)
|
|
42
55
|
rspec_junit_formatter (0.5.1)
|
|
43
56
|
rspec-core (>= 2, < 4, != 2.12.0)
|
|
44
|
-
rubocop (1.
|
|
57
|
+
rubocop (1.80.2)
|
|
58
|
+
json (~> 2.3)
|
|
59
|
+
language_server-protocol (~> 3.17.0.2)
|
|
60
|
+
lint_roller (~> 1.1.0)
|
|
45
61
|
parallel (~> 1.10)
|
|
46
|
-
parser (>= 3.
|
|
62
|
+
parser (>= 3.3.0.2)
|
|
47
63
|
rainbow (>= 2.2.2, < 4.0)
|
|
48
|
-
regexp_parser (>=
|
|
49
|
-
|
|
50
|
-
rubocop-ast (>= 1.17.0, < 2.0)
|
|
64
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
65
|
+
rubocop-ast (>= 1.46.0, < 2.0)
|
|
51
66
|
ruby-progressbar (~> 1.7)
|
|
52
|
-
unicode-display_width (>=
|
|
53
|
-
rubocop-ast (1.
|
|
54
|
-
parser (>= 3.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
standard (1.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
68
|
+
rubocop-ast (1.47.1)
|
|
69
|
+
parser (>= 3.3.7.2)
|
|
70
|
+
prism (~> 1.4)
|
|
71
|
+
rubocop-performance (1.25.0)
|
|
72
|
+
lint_roller (~> 1.1)
|
|
73
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
74
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
|
75
|
+
ruby-progressbar (1.13.0)
|
|
76
|
+
sidekiq (7.3.7)
|
|
77
|
+
connection_pool (>= 2.3.0)
|
|
78
|
+
logger
|
|
79
|
+
rack (>= 2.2.4)
|
|
80
|
+
redis-client (>= 0.22.2)
|
|
81
|
+
standard (1.51.1)
|
|
82
|
+
language_server-protocol (~> 3.17.0.2)
|
|
83
|
+
lint_roller (~> 1.0)
|
|
84
|
+
rubocop (~> 1.80.2)
|
|
85
|
+
standard-custom (~> 1.0.0)
|
|
86
|
+
standard-performance (~> 1.8)
|
|
87
|
+
standard-custom (1.0.2)
|
|
88
|
+
lint_roller (~> 1.0)
|
|
89
|
+
rubocop (~> 1.50)
|
|
90
|
+
standard-performance (1.8.0)
|
|
91
|
+
lint_roller (~> 1.1)
|
|
92
|
+
rubocop-performance (~> 1.25.0)
|
|
93
|
+
unicode-display_width (3.2.0)
|
|
94
|
+
unicode-emoji (~> 4.1)
|
|
70
95
|
|
|
71
96
|
PLATFORMS
|
|
72
97
|
ruby
|
|
@@ -76,10 +101,10 @@ DEPENDENCIES
|
|
|
76
101
|
rake (~> 12.0)
|
|
77
102
|
rspec (~> 3.2)
|
|
78
103
|
rspec_junit_formatter
|
|
79
|
-
sidekiq (=
|
|
80
|
-
sidekiq-pro (=
|
|
104
|
+
sidekiq (= 7.3.7)
|
|
105
|
+
sidekiq-pro (= 7.3.6)!
|
|
81
106
|
simplekiq!
|
|
82
107
|
standard
|
|
83
108
|
|
|
84
109
|
BUNDLED WITH
|
|
85
|
-
2.
|
|
110
|
+
2.7.2
|
data/README.md
CHANGED
|
@@ -107,6 +107,17 @@ end
|
|
|
107
107
|
|
|
108
108
|
See the [Simplekiq::BatchingJob](./lib/simplekiq/batching_job.rb) module itself for a description and example usage in the header comments. Nutshell is that you should use this if you're planning on making a batched asynchronous process as it shaves off a lot of ceremony and unexpressive structure. eg - Instead of having `BeerBottlerJob` which queues some number of `BeerBottlerBatchJob`s to handle the broken down sub-tasks you can just have `BeerBottlerJob` with a method for batching, executing individual batches, and a callback that gets run after all batches have completed successfully.
|
|
109
109
|
|
|
110
|
+
By default the generated `SimplekiqBatch` class inherits from `Simplekiq::BaseBatch` and only gets Sidekiq's global default options. If your job has a base class (e.g. `ApplicationJob`) whose behavior the batch class should share, opt in with `batch_inherits_from_superclass!`:
|
|
111
|
+
|
|
112
|
+
```ruby
|
|
113
|
+
class MyBatchJob < ApplicationJob
|
|
114
|
+
include Simplekiq::BatchingJob
|
|
115
|
+
batch_inherits_from_superclass!
|
|
116
|
+
|
|
117
|
+
batch_sidekiq_options queue: "low" # still takes precedence over ApplicationJob's options
|
|
118
|
+
end
|
|
119
|
+
```
|
|
120
|
+
|
|
110
121
|
## History
|
|
111
122
|
|
|
112
123
|
Simplekiq was initially released for private use within Doximity applications in Oct 2020 where it continued to be iterated on towards stability and general use until Jan 2022 when it was deemed settled enough for public release.
|
|
@@ -61,14 +61,13 @@
|
|
|
61
61
|
|
|
62
62
|
module Simplekiq
|
|
63
63
|
module BatchingJob
|
|
64
|
-
include Sidekiq::
|
|
64
|
+
include Sidekiq::Job
|
|
65
65
|
|
|
66
66
|
BATCH_CLASS_NAME = "SimplekiqBatch"
|
|
67
67
|
|
|
68
68
|
class << self
|
|
69
69
|
def included(klass)
|
|
70
|
-
|
|
71
|
-
klass.const_set(BATCH_CLASS_NAME, batch_job_class)
|
|
70
|
+
klass.const_set(BATCH_CLASS_NAME, Class.new(BaseBatch))
|
|
72
71
|
|
|
73
72
|
klass.extend ClassMethods
|
|
74
73
|
end
|
|
@@ -76,11 +75,41 @@ module Simplekiq
|
|
|
76
75
|
|
|
77
76
|
module ClassMethods
|
|
78
77
|
def batch_sidekiq_options(options)
|
|
78
|
+
(@simplekiq_batch_sidekiq_options ||= {}).merge!(options)
|
|
79
|
+
|
|
79
80
|
batch_class = const_get(BATCH_CLASS_NAME)
|
|
80
81
|
batch_class.instance_eval do
|
|
81
82
|
sidekiq_options(options)
|
|
82
83
|
end
|
|
83
84
|
end
|
|
85
|
+
|
|
86
|
+
# Opt in to having the generated batch class (<Job>::SimplekiqBatch)
|
|
87
|
+
# inherit from this job's own superclass (e.g. ApplicationJob) instead of
|
|
88
|
+
# Simplekiq::BaseBatch. The batch class then picks up whatever the
|
|
89
|
+
# superclass provides: sidekiq_options defaults, logging hooks, etc.
|
|
90
|
+
#
|
|
91
|
+
# Without calling this, the batch class keeps inheriting from
|
|
92
|
+
# Simplekiq::BaseBatch and only gets Sidekiq's global default options.
|
|
93
|
+
#
|
|
94
|
+
# May be called before or after batch_sidekiq_options; options already set
|
|
95
|
+
# through batch_sidekiq_options are re-applied and take precedence over the
|
|
96
|
+
# superclass's options.
|
|
97
|
+
def batch_inherits_from_superclass!
|
|
98
|
+
explicit_options = @simplekiq_batch_sidekiq_options
|
|
99
|
+
batch_job_class = Class.new(superclass) do
|
|
100
|
+
# Re-including Sidekiq::Job in a subclass resets the inherited
|
|
101
|
+
# sidekiq_options, so only include it if the superclass lacks
|
|
102
|
+
# Sidekiq's class methods. Checking ancestry isn't enough: when
|
|
103
|
+
# Sidekiq::Job is included via a plain module, the superclass has it
|
|
104
|
+
# as an ancestor but never received the class methods.
|
|
105
|
+
include Sidekiq::Job unless superclass.respond_to?(:sidekiq_options)
|
|
106
|
+
include BatchPerform
|
|
107
|
+
end
|
|
108
|
+
batch_job_class.sidekiq_options(explicit_options) if explicit_options && !explicit_options.empty?
|
|
109
|
+
|
|
110
|
+
send(:remove_const, BATCH_CLASS_NAME)
|
|
111
|
+
const_set(BATCH_CLASS_NAME, batch_job_class)
|
|
112
|
+
end
|
|
84
113
|
end
|
|
85
114
|
|
|
86
115
|
def perform(*args)
|
|
@@ -93,10 +122,10 @@ module Simplekiq
|
|
|
93
122
|
# to toggle the behavior on and off.
|
|
94
123
|
if batch
|
|
95
124
|
batch.jobs do
|
|
96
|
-
|
|
125
|
+
flush_batches(args)
|
|
97
126
|
end
|
|
98
127
|
else
|
|
99
|
-
|
|
128
|
+
flush_batches(args)
|
|
100
129
|
end
|
|
101
130
|
end
|
|
102
131
|
|
|
@@ -104,14 +133,6 @@ module Simplekiq
|
|
|
104
133
|
|
|
105
134
|
attr_accessor :batches
|
|
106
135
|
|
|
107
|
-
def handle_batches(args)
|
|
108
|
-
if !batches.empty?
|
|
109
|
-
flush_batches(args)
|
|
110
|
-
else
|
|
111
|
-
Simplekiq.run_empty_callbacks(self, args: args)
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
136
|
def flush_batches(args)
|
|
116
137
|
batch_job_class = self.class.const_get(BATCH_CLASS_NAME)
|
|
117
138
|
sidekiq_batch.description ||= "Simplekiq Batch Jobs for #{self.class.name}, args: #{args}"
|
|
@@ -140,9 +161,7 @@ module Simplekiq
|
|
|
140
161
|
end
|
|
141
162
|
end
|
|
142
163
|
|
|
143
|
-
|
|
144
|
-
include Sidekiq::Worker
|
|
145
|
-
|
|
164
|
+
module BatchPerform
|
|
146
165
|
def perform(*args)
|
|
147
166
|
module_parent_of_class.new.perform_batch(*args)
|
|
148
167
|
end
|
|
@@ -151,8 +170,13 @@ module Simplekiq
|
|
|
151
170
|
|
|
152
171
|
def module_parent_of_class
|
|
153
172
|
# Borrowed from https://apidock.com/rails/Module/module_parent_name
|
|
154
|
-
parent_name = self.class.name =~ /::[^:]+\Z/ ? $`.freeze : nil
|
|
173
|
+
parent_name = (self.class.name =~ /::[^:]+\Z/) ? $`.freeze : nil
|
|
155
174
|
parent_name ? Object.const_get(parent_name) : Object
|
|
156
175
|
end
|
|
157
176
|
end
|
|
177
|
+
|
|
178
|
+
class BaseBatch
|
|
179
|
+
include Sidekiq::Job
|
|
180
|
+
include BatchPerform
|
|
181
|
+
end
|
|
158
182
|
end
|
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
module Simplekiq
|
|
4
4
|
class OrchestrationExecutor
|
|
5
5
|
def self.execute(args:, job:, workflow:)
|
|
6
|
-
if workflow.empty?
|
|
7
|
-
Simplekiq.run_empty_callbacks(job, args: args)
|
|
8
|
-
return
|
|
9
|
-
end
|
|
10
|
-
|
|
11
6
|
orchestration_batch = Sidekiq::Batch.new
|
|
12
7
|
orchestration_batch.description = "#{job.class.name} Simplekiq orchestration"
|
|
13
8
|
Simplekiq.auto_define_callbacks(orchestration_batch, args: args, job: job)
|
|
@@ -15,7 +10,7 @@ module Simplekiq
|
|
|
15
10
|
orchestration_batch.jobs do
|
|
16
11
|
Simplekiq::BatchTrackerJob.perform_async(job.class.name, orchestration_batch.bid, args)
|
|
17
12
|
|
|
18
|
-
new.run_step(workflow, 0)
|
|
13
|
+
new.run_step(workflow, 0) unless workflow.empty?
|
|
19
14
|
end
|
|
20
15
|
end
|
|
21
16
|
|
data/lib/simplekiq/version.rb
CHANGED
data/lib/simplekiq.rb
CHANGED
|
@@ -11,13 +11,6 @@ require "simplekiq/batch_tracker_job"
|
|
|
11
11
|
|
|
12
12
|
module Simplekiq
|
|
13
13
|
class << self
|
|
14
|
-
# Empty batches with no jobs will never invoke callbacks, so handle
|
|
15
|
-
# that case by immediately manually invoking :complete & :success.
|
|
16
|
-
def run_empty_callbacks(job, args:)
|
|
17
|
-
job.on_complete(nil, {"args" => args}) if job.respond_to?(:on_complete)
|
|
18
|
-
job.on_success(nil, {"args" => args}) if job.respond_to?(:on_success)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
14
|
def auto_define_callbacks(batch, args:, job:)
|
|
22
15
|
batch.on("death", job.class, "args" => args) if job.respond_to?(:on_death)
|
|
23
16
|
batch.on("complete", job.class, "args" => args) if job.respond_to?(:on_complete)
|
data/simplekiq.gemspec
CHANGED
|
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
|
|
|
29
29
|
spec.add_development_dependency "pry"
|
|
30
30
|
spec.add_development_dependency "standard"
|
|
31
31
|
|
|
32
|
-
spec.add_dependency "sidekiq", ">=
|
|
33
|
-
spec.add_dependency "sidekiq-pro", "
|
|
32
|
+
spec.add_dependency "sidekiq", ">= 7.1", "< 9.0"
|
|
33
|
+
spec.add_dependency "sidekiq-pro", ">= 7.1", "< 9.0"
|
|
34
34
|
end
|
data/tasks/ci.rake
CHANGED
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simplekiq
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jack Noble
|
|
8
8
|
- John Wilkinson
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: rspec
|
|
@@ -87,28 +86,40 @@ dependencies:
|
|
|
87
86
|
requirements:
|
|
88
87
|
- - ">="
|
|
89
88
|
- !ruby/object:Gem::Version
|
|
90
|
-
version:
|
|
89
|
+
version: '7.1'
|
|
90
|
+
- - "<"
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '9.0'
|
|
91
93
|
type: :runtime
|
|
92
94
|
prerelease: false
|
|
93
95
|
version_requirements: !ruby/object:Gem::Requirement
|
|
94
96
|
requirements:
|
|
95
97
|
- - ">="
|
|
96
98
|
- !ruby/object:Gem::Version
|
|
97
|
-
version:
|
|
99
|
+
version: '7.1'
|
|
100
|
+
- - "<"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '9.0'
|
|
98
103
|
- !ruby/object:Gem::Dependency
|
|
99
104
|
name: sidekiq-pro
|
|
100
105
|
requirement: !ruby/object:Gem::Requirement
|
|
101
106
|
requirements:
|
|
102
|
-
- - "
|
|
107
|
+
- - ">="
|
|
103
108
|
- !ruby/object:Gem::Version
|
|
104
|
-
version: '
|
|
109
|
+
version: '7.1'
|
|
110
|
+
- - "<"
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: '9.0'
|
|
105
113
|
type: :runtime
|
|
106
114
|
prerelease: false
|
|
107
115
|
version_requirements: !ruby/object:Gem::Requirement
|
|
108
116
|
requirements:
|
|
109
|
-
- - "
|
|
117
|
+
- - ">="
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: '7.1'
|
|
120
|
+
- - "<"
|
|
110
121
|
- !ruby/object:Gem::Version
|
|
111
|
-
version: '
|
|
122
|
+
version: '9.0'
|
|
112
123
|
description: Provides tools for representing long chains of parallel and serial jobs
|
|
113
124
|
in a flat, simple way.
|
|
114
125
|
email:
|
|
@@ -145,7 +156,6 @@ licenses:
|
|
|
145
156
|
metadata:
|
|
146
157
|
homepage_uri: https://github.com/doximity/simplekiq
|
|
147
158
|
source_code_uri: https://github.com/doximity/simplekiq
|
|
148
|
-
post_install_message:
|
|
149
159
|
rdoc_options: []
|
|
150
160
|
require_paths:
|
|
151
161
|
- lib
|
|
@@ -160,8 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
160
170
|
- !ruby/object:Gem::Version
|
|
161
171
|
version: '0'
|
|
162
172
|
requirements: []
|
|
163
|
-
rubygems_version: 3.
|
|
164
|
-
signing_key:
|
|
173
|
+
rubygems_version: 3.6.9
|
|
165
174
|
specification_version: 4
|
|
166
175
|
summary: Sidekiq-based workflow orchestration library
|
|
167
176
|
test_files: []
|