ixti / sidekiq-throttled

Concurrency and rate-limit throttling for Sidekiq
MIT License
709 stars 76 forks source link

Does sidekiq-throttled works well with sidekiq-cron? #90

Closed hubertjakubiak closed 4 years ago

hubertjakubiak commented 4 years ago

My configuration:

Sidekiq.configure_server do |config|
  config.redis = {
    url: "#{Rails.application.credentials.redis_url}/1"
  }
  Sidekiq::Cron::Job.load_from_array!(schedule)
end

Sidekiq.configure_client do |config|
  config.redis = {
    url: "#{Rails.application.credentials.redis_url}/1"
  }
end

Sidekiq::Throttled.setup!
Sidekiq::Throttled::Registry.add(:limited_concurrency, { concurrency: { limit: 10 } })

and error I'm getting:

bundle exec sidekiq
2020-10-08T08:06:36.720Z pid=9100 tid=oxmw2orlc INFO: Booting Sidekiq 6.1.2 with redis options {:url=>"redis://localhost:6379/1"}
2020-10-08T08:06:36.738Z pid=9100 tid=oxmw2orlc WARN: RuntimeError: Strategy not found: limited_concurrency
2020-10-08T08:06:36.738Z pid=9100 tid=oxmw2orlc WARN: /Users/hubertjakubiak/.rvm/gems/ruby-2.6.5/gems/sidekiq-throttled-0.13.0/lib/sidekiq/throttled/registry.rb:44:in `add_alias'
hubertjakubiak commented 4 years ago

I moved line Sidekiq::Cron::Job.load_from_array!(schedule) to the end of file - Sidekiq::Cron::Job.load_from_array(schedule) if Sidekiq.server? and it works.