-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enqueue-multi compatibility fixes #1
base: master
Are you sure you want to change the base?
Conversation
354d46d
to
4337268
Compare
4337268
to
0a8be8e
Compare
66fcdd2
to
d7452f7
Compare
35d0cc2
to
6cd37a1
Compare
3feb932
to
3686b62
Compare
- "3.0" | ||
- "3.1" | ||
- "3.2" | ||
- "3.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to later released ruby
- "~> 5.x" | ||
- "~> 3.3" | ||
- "~> 4.8" | ||
- "~> 5.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may update the matrix again, but trying to ensure this is relatively complete, with ruby 3.0+ supporting versions and in-use redis versions. will need to look at the gemspec constraints too
AllCops: | ||
TargetRubyVersion: 3.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simplified/resolved rubocop due to updates, and supporting ruby 3.
I'm happy to remove the todo (since it covers stuff not in the below Include)
@@ -1,4 +1,3 @@ | |||
# vim:fileencoding=utf-8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was in every file and is now a default cop, so cleaned up. IIRC its not necessary.
@@ -204,25 +202,36 @@ def enqueue_next_item(timestamp) | |||
item | |||
end | |||
|
|||
def batch_delayed_items? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This starts the refactor that revives the 'non batched' mode by deciding if batching is appropriate
log "queued batch of #{actual_batch_size} jobs" if actual_batch_size != -1 | ||
else | ||
item = enqueue_next_item(timestamp) | ||
actual_batch_size = item.nil? ? 0 : 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non batched version
def delayed_requeue_batch_size | ||
@delayed_requeue_batch_size ||= \ | ||
ENV['DELAYED_REQUEUE_BATCH_SIZE'].to_i if environment['DELAYED_REQUEUE_BATCH_SIZE'] | ||
@delayed_requeue_batch_size ||= 100 | ||
end | ||
|
||
attr_writer :enable_delayed_requeue_batches | ||
|
||
def enable_delayed_requeue_batches |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config to enable batches (off by default)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to reversing this - and making on by default to coincide with the latest behavior of the gem.
@@ -1,27 +1,26 @@ | |||
# vim:fileencoding=utf-8 | |||
lib = File.expand_path('../lib', __FILE__) | |||
lib = File.expand_path('lib', __dir__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rubocop updates
require_relative 'test_helper' | ||
|
||
def assert_resque_key_exists?(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better support for deprecations on redis
test/delayed_queue_test.rb
Outdated
@@ -383,60 +390,140 @@ | |||
assert_equal(1, Resque.delayed_timestamp_peek(t, 0, 3).length) | |||
end | |||
|
|||
test 'enqueue_delayed_items_for_timestamp enqueues jobs in 2 batches' do | |||
t = Time.now + 60 | |||
context 'non-batch delayed item queue' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test for batch v non batch
aca4153
to
88236f5
Compare
ccd84b1
to
77e2793
Compare
77e2793
to
4bdb097
Compare
gem 'racc' | ||
gem 'rubocop', '~> 1.4' | ||
gem 'rubocop-minitest' | ||
gem 'rubocop-rake' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved development dependencies into the gemfile
def delayed_requeue_batch_size | ||
@delayed_requeue_batch_size ||= \ | ||
ENV['DELAYED_REQUEUE_BATCH_SIZE'].to_i if environment['DELAYED_REQUEUE_BATCH_SIZE'] | ||
@delayed_requeue_batch_size ||= 100 | ||
end | ||
|
||
attr_writer :enable_delayed_requeue_batches | ||
|
||
def enable_delayed_requeue_batches |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to reversing this - and making on by default to coincide with the latest behavior of the gem.
@@ -383,60 +391,115 @@ | |||
assert_equal(1, Resque.delayed_timestamp_peek(t, 0, 3).length) | |||
end | |||
|
|||
test 'enqueue_delayed_items_for_timestamp enqueues jobs in 2 batches' do | |||
t = Time.now + 60 | |||
context "non-batch delayed item queue" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests to ensure both batch and non-batch work properly
@@ -307,7 +307,7 @@ module Test | |||
test 'redirects to overview' do | |||
post '/delayed/cancel_now' | |||
assert last_response.status == 302 | |||
assert last_response.header['Location'].include? '/delayed' | |||
assert last_response.headers['Location'].include? '/delayed' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updates to new rubies.
teardown do | ||
Resque::Scheduler.enable_delayed_requeue_batches = batch_enabled | ||
Resque::Scheduler.delayed_requeue_batch_size = batch_size | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking, I'm not sure I understand the need for this teardown step, more just understanding the spec. Shouldnt these be dumped between runs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can understand both sides re: default behavior. Opt-in for batching seems ok to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know a ton but love the thoroughness and updates, and the separate testing repo with matrix compatibility for different versions ✨
Add flag that enables/disables the batch enqueue mode for delayed jobs.
The batch enqueue mode causes issues because it starts a multi/pipeline, but this breaks a number of other plugins that rely on doing Redis work within that enqueue window.
The current approach is to make the batch behavior opt-in, with a flag. The documentation can then lay out the compatibility risks.
References:
This PR also updates compatibility with ruby 3.x, and associated dependencies, lints, deprecations, etc. I realize this creates a bigger PR with a few 'style' type changes, but it helped me immensely when working to resolve this.
Compatibility integration tests with other gems (just resque-lock-timeout for now) exist in this PR - this helps prove out the fix. I hope to keep this up to date with any changes.