simplekiq 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f267eca4633ec71afa7595061707ffdea9a94c9f7b0db7dde1296a6aa314f66f
4
- data.tar.gz: 52f52165d23bc71277f86c8c6ce049b42566b188ed484efa14cf974901e94dbe
3
+ metadata.gz: 69e0bcbcf55efac94c5089a8a781184585a72e73ca6ca348359435b116a6fdf1
4
+ data.tar.gz: 8f4e9ffab0ecf5d8794f0c0bfdf9fc5a01f13109ddf67f6b43b9886670148032
5
5
  SHA512:
6
- metadata.gz: c4722a45b623489cd739ff5cd2b41711fb0c5004bfcc3f7775eddb9b31f7c0a18a582b6d890531ade1bd6a06acc59497867b5db2725aaa15009b37ae21c0f4bf
7
- data.tar.gz: 0ee6f33a11201f94ce846968be2ec471c9292bc0e6d63bf6e7b3bc68eff688198714470405d4b0e5b32192a6e892b409964d7368b6050467ab6f350eae510875
6
+ metadata.gz: adebf247df4237916eeb104675cf8d819cfed1b546312b7bb94ae0177c927339d702a035445274ba652657a18d6d1a5366daef5fd70e8cbfec06c0b58d9d8d9b
7
+ data.tar.gz: f6bf6a6a79bb6c14e2fa7cadd285f96b0fc457f26065e464d25b5772ac4e43ee6a7034de5983a34d730a144e488ae9125280903a35241b3ecd073f517bac1a25
data/.circleci/config.yml CHANGED
@@ -12,26 +12,6 @@ executors:
12
12
  - image: redis:6.2
13
13
  command: redis-server
14
14
 
15
- # yaml anchor filters
16
- always_run: &always_run
17
- filters:
18
- branches:
19
- only: /.*/
20
- tags:
21
- only: /^v.*/
22
- pr_only: &pr_only
23
- filters:
24
- branches:
25
- ignore: master
26
- tags:
27
- ignore: /.*/
28
- version_tags_only: &version_tags_only
29
- filters:
30
- branches:
31
- ignore: /.*/
32
- tags:
33
- only: /^v.*/
34
-
35
15
  jobs:
36
16
  build:
37
17
  executor: ruby-with-redis
@@ -63,8 +43,7 @@ jobs:
63
43
  workflows:
64
44
  main:
65
45
  jobs:
66
- - build:
67
- <<: *always_run
46
+ - build:
68
47
  context:
69
48
  - sidekiq-enterprise
70
49
  - nexus_readonly
data/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ 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
+
7
19
  ## [1.0.0]
8
20
  * Only support Sidekiq 7.1 and Sidekiq 8 (dropped support for older versions)
9
21
  [#42](https://github.com/doximity/simplekiq/pull/42)
data/CONTRIBUTORS.md CHANGED
@@ -24,6 +24,7 @@
24
24
 
25
25
  ### Lucas Lazzaris (Doximity)
26
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)
27
28
 
28
29
  ### [Daniel Pepper](https://github.com/dpep)
29
30
  * On request, graciously took down his unused `simplekiq` placeholder from rubygems so we could continue using the name :raised_hands:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simplekiq (0.2.0)
4
+ simplekiq (1.1.0)
5
5
  sidekiq (>= 7.1, < 9.0)
6
6
  sidekiq-pro (>= 7.1, < 9.0)
7
7
 
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.
@@ -67,8 +67,7 @@ module Simplekiq
67
67
 
68
68
  class << self
69
69
  def included(klass)
70
- batch_job_class = Class.new(BaseBatch)
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)
@@ -132,9 +161,7 @@ module Simplekiq
132
161
  end
133
162
  end
134
163
 
135
- class BaseBatch
136
- include Sidekiq::Job
137
-
164
+ module BatchPerform
138
165
  def perform(*args)
139
166
  module_parent_of_class.new.perform_batch(*args)
140
167
  end
@@ -147,4 +174,9 @@ module Simplekiq
147
174
  parent_name ? Object.const_get(parent_name) : Object
148
175
  end
149
176
  end
177
+
178
+ class BaseBatch
179
+ include Sidekiq::Job
180
+ include BatchPerform
181
+ end
150
182
  end
@@ -1,3 +1,3 @@
1
1
  module Simplekiq
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
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: 1.0.0
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: 2025-11-10 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
@@ -157,7 +156,6 @@ licenses:
157
156
  metadata:
158
157
  homepage_uri: https://github.com/doximity/simplekiq
159
158
  source_code_uri: https://github.com/doximity/simplekiq
160
- post_install_message:
161
159
  rdoc_options: []
162
160
  require_paths:
163
161
  - lib
@@ -172,8 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
170
  - !ruby/object:Gem::Version
173
171
  version: '0'
174
172
  requirements: []
175
- rubygems_version: 3.3.26
176
- signing_key:
173
+ rubygems_version: 3.6.9
177
174
  specification_version: 4
178
175
  summary: Sidekiq-based workflow orchestration library
179
176
  test_files: []