lib/sidekiq/throttled.rb in sidekiq-throttled-0.10.0.beta vs lib/sidekiq/throttled.rb in sidekiq-throttled-0.10.0
- old
+ new
@@ -4,13 +4,15 @@
require "sidekiq"
# internal
require "sidekiq/throttled/version"
require "sidekiq/throttled/communicator"
+require "sidekiq/throttled/configuration"
require "sidekiq/throttled/queues_pauser"
require "sidekiq/throttled/registry"
require "sidekiq/throttled/worker"
+require "sidekiq/throttled/utils"
# @see https://github.com/mperham/sidekiq/
module Sidekiq
# Concurrency and threshold throttling for Sidekiq.
#
@@ -42,10 +44,17 @@
module Throttled
MUTEX = Mutex.new
private_constant :MUTEX
class << self
+ include Utils
+
+ # @return [Configuration]
+ def configuration
+ @configuration ||= Configuration.new
+ end
+
# Hooks throttler into sidekiq.
#
# @return [void]
def setup!
Communicator.instance.setup!
@@ -96,19 +105,9 @@
def preload_constant!(job)
MUTEX.synchronize do
@preloaded ||= {}
@preloaded[job] ||= constantize(job) || true
end
- end
-
- # Resolve constant from it's name
- def constantize(str)
- str.sub(/^::/, "").split("::").inject(Object) do |const, name|
- const.const_get(name)
- end
- rescue
- Sidekiq.logger.warn { "Failed to constantize: #{str}" }
- nil
end
end
end
end