Skip to content

Commit

Permalink
Use Sidekiq::Cron configuration for cron_poll_interval and refactor r…
Browse files Browse the repository at this point in the history
…equires in sidekiq-cron.rb
  • Loading branch information
satyakampandya committed Oct 8, 2024
1 parent 08f4fb9 commit bc9327a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 5 additions & 0 deletions lib/sidekiq-cron.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
require "sidekiq"
require "sidekiq/cron"
require "sidekiq/cron/job"
require "sidekiq/cron/namespace"
require "sidekiq/cron/poller"
require "sidekiq/cron/launcher"
require "sidekiq/cron/schedule_loader"
5 changes: 0 additions & 5 deletions lib/sidekiq/cron.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
require "sidekiq/cron/job"
require "sidekiq/cron/namespace"
require "sidekiq/cron/poller"
require "sidekiq/cron/launcher"

module Sidekiq
module Cron
class << self
Expand Down
1 change: 1 addition & 0 deletions lib/sidekiq/cron/launcher.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'sidekiq/cron'
require 'sidekiq/cron/poller'

# For Cron we need to add some methods to Launcher
Expand Down
4 changes: 2 additions & 2 deletions test/unit/launcher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

it 'initializes poller with default poll interval when not configured' do
Sidekiq::Cron::Poller.expects(:new).with do |options|
assert_equal 30, options[:cron_poll_interval]
assert_equal Sidekiq::Cron.configuration.cron_poll_interval, options[:cron_poll_interval]
end

Sidekiq::Launcher.new(Sidekiq::Options.config)
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]
assert_equal Sidekiq::Cron.configuration.cron_poll_interval, options[:cron_poll_interval]
end

Sidekiq::Cron.configuration.cron_poll_interval = 99
Expand Down

0 comments on commit bc9327a

Please sign in to comment.