Class: Berkshelf::API::CacheBuilder
- Inherits:
-
Object
- Object
- Berkshelf::API::CacheBuilder
- Includes:
- GenericServer, Logging, Mixin::Services
- Defined in:
- lib/berkshelf/api/cache_builder.rb,
lib/berkshelf/api/cache_builder/worker.rb,
lib/berkshelf/api/cache_builder/worker/github.rb,
lib/berkshelf/api/cache_builder/worker/file_store.rb,
lib/berkshelf/api/cache_builder/worker/chef_server.rb,
lib/berkshelf/api/cache_builder/worker/supermarket.rb
Defined Under Namespace
Modules: Worker Classes: WorkerSupervisor
Instance Method Summary collapse
- #build ⇒ Object
-
#build_loop(interval = @build_interval) ⇒ Object
Issue a build command to all workers at the scheduled interval.
-
#initialize ⇒ CacheBuilder
constructor
A new instance of CacheBuilder.
-
#workers ⇒ Array<CacheBuilder::Worker::Base>
Return the list of running workers.
Methods included from Mixin::Services
Methods included from Logging
Methods included from GenericServer
Constructor Details
#initialize ⇒ CacheBuilder
Returns a new instance of CacheBuilder.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/berkshelf/api/cache_builder.rb', line 14 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. || {}).to_hash.deep_symbolize_keys @worker_supervisor.supervise(CacheBuilder::Worker[endpoint.type], .merge(priority: index)) end end |
Instance Method Details
#build ⇒ Object
27 28 29 |
# File 'lib/berkshelf/api/cache_builder.rb', line 27 def build cache_manager.process_workers(workers) end |
#build_loop(interval = @build_interval) ⇒ Object
Issue a build command to all workers at the scheduled interval
34 35 36 37 38 39 40 41 42 |
# File 'lib/berkshelf/api/cache_builder.rb', line 34 def build_loop(interval = @build_interval) return if @building loop do @building = true build sleep interval end end |
#workers ⇒ Array<CacheBuilder::Worker::Base>
Return the list of running workers
47 48 49 |
# File 'lib/berkshelf/api/cache_builder.rb', line 47 def workers @worker_supervisor.actors end |