lib/berkshelf/api/cache_builder.rb in berkshelf-api-2.0.0 vs lib/berkshelf/api/cache_builder.rb in berkshelf-api-2.1.0

- old
+ new

@@ -2,12 +2,10 @@ class CacheBuilder require_relative 'cache_builder/worker' class WorkerSupervisor < Celluloid::SupervisionGroup; end - BUILD_INTERVAL = 5.0 - include Berkshelf::API::GenericServer include Berkshelf::API::Logging include Berkshelf::API::Mixin::Services server_name :cache_builder @@ -16,10 +14,11 @@ def initialize log.info "Cache Builder starting..." @worker_registry = Celluloid::Registry.new @worker_supervisor = WorkerSupervisor.new(@worker_registry) @building = false + @build_interval = Application.config.build_interval Application.config.endpoints.each_with_index do |endpoint, index| endpoint_options = (endpoint.options || {}).to_hash.deep_symbolize_keys @worker_supervisor.supervise(CacheBuilder::Worker[endpoint.type], endpoint_options.merge(priority: index)) end @@ -30,10 +29,10 @@ end # Issue a build command to all workers at the scheduled interval # # @param [Fixnum, Float] interval - def build_loop(interval = BUILD_INTERVAL) + def build_loop(interval = @build_interval) return if @building loop do @building = true build