sidekiq-corral 0.1.0 → 1.0.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: 7b439de1e2bbdf25862994d714547b2f5f33a1e44ab7d95129a2635537a1efa4
4
- data.tar.gz: 5c7580ca96ec6d8b94eef39b7aaae766182fdf7b6f486628e329de8d3946e14e
3
+ metadata.gz: 4d79f491ec4630670f6492574d4248a4b059fb0b08f5453282a93c32c9ec1790
4
+ data.tar.gz: 2d82118f902e1f228cbd2a2f6c9b623ad95915a8ed5292a7f753b1b9e37dad6a
5
5
  SHA512:
6
- metadata.gz: 1d9b1923a16971cc9ad0a185d435a48ba43baed28b401e57c092e6686ed21dbe0cbde308a0c2ece0ec0e556ca5fb19c3782f3151cb791f6fa735dcfdcde515b2
7
- data.tar.gz: 4275fa4e6f59f422ce8627c98fd23d2ece312e20895c31459eed20fa3f5f23b09f8e6156a4724b9f5c927251c40691cd4a72ec08f1ff1b84beffcabd9808c19b
6
+ metadata.gz: 5169b1ce203ec3c2848982eca02c14a6fe9886712576294c79f3f7264cb183b8bae4e44689390007654ee921e1323f2946dcb87695c7bd6521a14142f745ae48
7
+ data.tar.gz: a826f835bb55ed547b040d7c82f6e3a5595d15601f12f948fa146d194714beba0c161ea780512c0dd714aa07b5cd420e192395e980958bfb36ce8d02405142e4
data/CHANGELOG.md CHANGED
@@ -1,8 +1,26 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.0.0] - 2026-12-02
4
+
5
+ ### Added
6
+
7
+ - Support for Sidekiq 7 and 8
8
+
9
+ ### Changed
10
+
11
+ - Corral names are always Strings: a Symbol given to `set(corral:)` or `Sidekiq::Corral.confine` is stored in the job, and returned by `Sidekiq::Corral.current`, as a String
12
+
13
+ ### Removed
14
+
15
+ - Support for Ruby 2.7 and 3.0
16
+ - Support for Sidekiq 6.0 through 6.4
17
+
3
18
  ## [0.1.0] - 2023-07-24
4
19
 
20
+ ### Added
21
+
5
22
  - Initial release
6
23
 
7
- [Unreleased]: https://github.com/planningcenter/edna/compare/v1.0.0..main
8
- [0.1.0]: https://github.com/planningcenter/edna/compare/502876a..v0.1.0
24
+ [Unreleased]: https://github.com/molawson/sidekiq-corral/compare/v1.0.0..main
25
+ [1.0.0]: https://github.com/molawson/sidekiq-corral/compare/v0.1.0..v1.0.0
26
+ [0.1.0]: https://github.com/molawson/sidekiq-corral/commits/v0.1.0
data/README.md CHANGED
@@ -13,15 +13,13 @@ That's exactly where Sidekiq::Corral comes in!
13
13
 
14
14
  ## Installation
15
15
 
16
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
17
-
18
16
  Install the gem and add to the application's Gemfile by executing:
19
17
 
20
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+ $ bundle add sidekiq-corral
21
19
 
22
20
  If bundler is not being used to manage dependencies, install the gem by executing:
23
21
 
24
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
22
+ $ gem install sidekiq-corral
25
23
 
26
24
  Install the middleware on application boot (e.g. in a Rails initializer or wherever you're configuring other parts of Sidekiq):
27
25
 
@@ -48,21 +46,25 @@ This will both set the corral and the queue for that job and any job enqueued du
48
46
  If you're enqueueing multiple jobs or calling classes that enqueue jobs of their own and you want to confine everything to a single queue, you can use `Sidekiq::Corral.confine`:
49
47
 
50
48
  ```ruby
51
- Sidekiq::Corral.confne("backfill") do
49
+ Sidekiq::Corral.confine("backfill") do
52
50
  SomeJob.perform_async(args)
53
51
  ClassThatEnqueuesJobs.new.call(more_args)
54
- AnotherJob.peform_async(even_more_args)
52
+ AnotherJob.perform_async(even_more_args)
55
53
  end
56
54
  ```
57
55
 
58
56
  All jobs enqueued within that block (including those enqueued in `ClassThatEnqueuesJobs`, etc.) will be put in the `"backfill"` corral and processed on the `"backfill"` queue.
59
57
 
58
+ ### Corral names are Strings
59
+
60
+ You can pass a corral as a Symbol to `set` or `confine`, but it's always stored as a String, like Sidekiq's queue names. `Sidekiq::Corral.current` returns `"backfill"` after `confine(:backfill)`, both where the job is enqueued and inside the job, and the job's `"corral"` and `"queue"` are `"backfill"` too.
61
+
60
62
 
61
63
  ### Exempt Queues
62
64
 
63
65
  Sometimes a queue is special enough that you always want jobs destined for it to _always_ be processed there, regardless of Sidekiq::Corral's concerns. You can name those queues on setup:
64
66
 
65
- ```ruby
67
+ ```ruby
66
68
  Sidekiq::Corral.install(exempt_queues: ["notifications"])
67
69
  ```
68
70
 
@@ -84,7 +86,7 @@ class SpecialJob
84
86
  include Sidekiq::Job
85
87
  sidekiq_options queue: "notifications"
86
88
 
87
- def peform
89
+ def perform
88
90
  AnotherNormalJob.perform_async
89
91
  end
90
92
  end
@@ -103,16 +105,35 @@ Enqueuing the NormalJob with a corral would get processed like so:
103
105
  ```ruby
104
106
  NormalJob.set(corral: "backfill").perform_async
105
107
 
106
- NormalJob # queue: "backfill". corral: "backfill"
108
+ NormalJob # queue: "backfill" corral: "backfill"
107
109
  -> SpecialJob # queue: "notifications" corral: "backfill"
108
110
  -> AnotherNormalJob # queue: "backfill" corral: "backfill"
109
111
  ```
110
112
 
113
+ ### Sidekiq Pro batch callbacks
114
+
115
+ Batch callbacks don't inherit the corral of the jobs in the batch: a callback runs on its own queue even when every job in the batch ran in a corral. If a callback needs to run in the corral, set its queue yourself.
116
+
111
117
 
112
118
  ## Development
113
119
 
114
120
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
115
121
 
122
+ `rake test:server` runs the middleware in an embedded Sidekiq server (Sidekiq 7+). Because the server registers itself and writes stats in Redis, it only runs when you set `REDIS_URL` explicitly, ideally to a Redis database nothing else uses. `rake` runs both.
123
+
124
+ ### Testing against multiple Sidekiq versions
125
+
126
+ The root `Gemfile.lock` is for everyday development. CI also runs the tests against each supported Sidekiq version using [Appraisal](https://github.com/thoughtbot/appraisal), which keeps a gemfile and lockfile per version in `gemfiles/`, generated from `Appraisals`.
127
+
128
+ ```sh
129
+ bundle exec appraisal install # install the gems for every version
130
+ bundle exec appraisal rake test # run the tests against every version
131
+ bundle exec appraisal sidekiq-7.3 rake test # run the tests against one version
132
+ bundle exec appraisal list # list the versions
133
+ ```
134
+
135
+ After changing the `Gemfile` or `Appraisals`, run `bundle exec appraisal install` and commit the regenerated files in `gemfiles/`. To update the gems in those lockfiles, run `bundle exec appraisal update`.
136
+
116
137
  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`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
117
138
 
118
139
  ## Contributing
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Corral
5
- VERSION = "0.1.0"
5
+ VERSION = "1.0.0"
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ module Sidekiq
12
12
  class << self
13
13
  def confine(queue)
14
14
  orig_queue = current
15
- self.current = queue
15
+ self.current = queue&.to_s
16
16
  yield
17
17
  ensure
18
18
  self.current = orig_queue
@@ -49,8 +49,11 @@ module Sidekiq
49
49
  end
50
50
 
51
51
  def call(_worker_class, job, _queue, _redis_pool)
52
- job["corral"] = Corral.current if Corral.current
53
- job["queue"] = job["corral"] if job["corral"] && !@exempt_queues.include?(job["queue"])
52
+ corral = Corral.current || job["corral"]
53
+ if corral
54
+ job["corral"] = corral.to_s
55
+ job["queue"] = job["corral"] unless @exempt_queues.include?(job["queue"])
56
+ end
54
57
  yield
55
58
  end
56
59
  end
metadata CHANGED
@@ -1,29 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-corral
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mo Lawson
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-07-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: sidekiq
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '6.0'
18
+ version: '6.5'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - "~>"
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '6.0'
25
+ version: '6.5'
27
26
  description: Send a job to a queue and move all jobs it triggers to that same queue.
28
27
  email:
29
28
  - mo@molawson.com
@@ -31,13 +30,10 @@ executables: []
31
30
  extensions: []
32
31
  extra_rdoc_files: []
33
32
  files:
34
- - ".rubocop.yml"
35
- - ".streerc"
36
33
  - CHANGELOG.md
37
34
  - CODE_OF_CONDUCT.md
38
35
  - LICENSE.txt
39
36
  - README.md
40
- - Rakefile
41
37
  - lib/sidekiq/corral.rb
42
38
  - lib/sidekiq/corral/version.rb
43
39
  - sig/sidekiq/corral.rbs
@@ -50,7 +46,6 @@ metadata:
50
46
  homepage_uri: https://github.com/molawson/sidekiq-corral
51
47
  source_code_uri: https://github.com/molawson/sidekiq-corral
52
48
  changelog_uri: https://github.com/molawson/sidekiq-corral/blob/main/CHANGELOG.md
53
- post_install_message:
54
49
  rdoc_options: []
55
50
  require_paths:
56
51
  - lib
@@ -58,15 +53,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
53
  requirements:
59
54
  - - ">="
60
55
  - !ruby/object:Gem::Version
61
- version: 2.7.0
56
+ version: 3.1.0
62
57
  required_rubygems_version: !ruby/object:Gem::Requirement
63
58
  requirements:
64
59
  - - ">="
65
60
  - !ruby/object:Gem::Version
66
61
  version: '0'
67
62
  requirements: []
68
- rubygems_version: 3.4.10
69
- signing_key:
63
+ rubygems_version: 3.6.9
70
64
  specification_version: 4
71
65
  summary: Confine a job and its child jobs to a single queue.
72
66
  test_files: []
data/.rubocop.yml DELETED
@@ -1,14 +0,0 @@
1
- require:
2
- - rubocop-minitest
3
- - rubocop-rake
4
-
5
- inherit_gem:
6
- syntax_tree: config/rubocop.yml
7
-
8
- AllCops:
9
- NewCops: enable
10
- TargetRubyVersion: 2.7
11
-
12
- # Match print_width option in .streerc
13
- Layout/LineLength:
14
- Max: 100
data/.streerc DELETED
@@ -1,2 +0,0 @@
1
- --print-width=100
2
- --plugins=plugin/trailing_comma
data/Rakefile DELETED
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rake/testtask"
5
-
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << "test"
8
- t.libs << "lib"
9
- t.test_files = FileList["test/**/test_*.rb"]
10
- end
11
-
12
- require "rubocop/rake_task"
13
- RuboCop::RakeTask.new
14
-
15
- require "syntax_tree/rake_tasks"
16
- SyntaxTree::Rake::CheckTask.new
17
- SyntaxTree::Rake::WriteTask.new
18
-
19
- task default: %i[test]