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/opscode.rb,
lib/berkshelf/api/cache_builder/worker/file_store.rb,
lib/berkshelf/api/cache_builder/worker/chef_server.rb
Defined Under Namespace
Modules: Worker Classes: WorkerSupervisor
Constant Summary collapse
- BUILD_INTERVAL =
5.0
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.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/berkshelf/api/cache_builder.rb', line 16 def initialize log.info "Cache Builder starting..." @worker_registry = Celluloid::Registry.new @worker_supervisor = WorkerSupervisor.new(@worker_registry) @building = false 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
28 29 30 |
# File 'lib/berkshelf/api/cache_builder.rb', line 28 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
35 36 37 38 39 40 41 42 43 |
# File 'lib/berkshelf/api/cache_builder.rb', line 35 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
48 49 50 |
# File 'lib/berkshelf/api/cache_builder.rb', line 48 def workers @worker_supervisor.actors end |