-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow disabling of cron polling (#368)
When running with very many Sidekiq processes, polling on each one of them can be expensive and unnecessary too. This allows disabling polling by setting `cron_poll_interval` to zero.
- Loading branch information
Showing
4 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require './test/test_helper' | ||
|
||
describe 'Cron launcher' do | ||
describe 'initialization' do | ||
before do | ||
Sidekiq[:cron_poll_interval] = nil | ||
end | ||
|
||
it 'initializes poller with default poll interval when not configured' do | ||
Sidekiq::Cron::Poller.expects(:new).with do |options| | ||
assert_equal Sidekiq::Cron::Launcher::DEFAULT_POLL_INTERVAL, options[:cron_poll_interval] | ||
end | ||
|
||
Sidekiq::Launcher.new(Sidekiq) | ||
end | ||
|
||
it 'initializes poller with the configured poll interval' do | ||
Sidekiq::Cron::Poller.expects(:new).with do |options| | ||
assert_equal 99, options[:cron_poll_interval] | ||
end | ||
|
||
Sidekiq[:cron_poll_interval] = 99 | ||
Sidekiq::Launcher.new(Sidekiq) | ||
end | ||
|
||
it 'does not initialize the poller when interval is 0' do | ||
Sidekiq::Cron::Poller.expects(:new).never | ||
|
||
Sidekiq[:cron_poll_interval] = 0 | ||
Sidekiq::Launcher.new(Sidekiq) | ||
end | ||
end | ||
end |