sidekiq-throttled
sidekiq-throttled copied to clipboard
sidekiq_throttle_as doesn't work in inherited classes
What's the problem?
The throttle is not being used in inherited classes. I've just noticed this by looking at the sidekiq web interface and realized that there were more jobs running than the defined in the throttle. And the running jobs in the throttle stats were zero.
Version: 0.15.0
How to reproduce it?
Implement a worker base and an inherited one:
class BaseWorker
include Sidekiq::Worker
include Sidekiq::Throttled::Worker
sidekiq_throttle_as :my_throttle
end
class ChildWorker < BaseWorker
end
Now use your worker and notice that the throttle will always be set to zero (no jobs in the throttle).
Another way of checking this behavior is to start more workers than the defined.
Where do I think that the problem is:
My guess is the problem lives inside the Registry#find_by_class that's used by Registry#get
Look at some discoveries that I've made in the Rails console:
> Sidekiq::Throttled::Registry.get(BaseWorker) # It returns an object
> Sidekiq::Throttled::Registry.get(ChildWorker) # It returns nil