Class: TopologicalInventory::Providers::Common::CollectorsPool
- Inherits:
-
Object
- Object
- TopologicalInventory::Providers::Common::CollectorsPool
- Defined in:
- lib/topological_inventory/providers/common/collectors_pool.rb
Constant Summary collapse
- SECRET_FILENAME =
"credentials".freeze
Instance Method Summary collapse
-
#initialize(config_name, metrics, collector_poll_time: 60, thread_pool_size: 2) ⇒ CollectorsPool
constructor
A new instance of CollectorsPool.
- #run! ⇒ Object
- #stop! ⇒ Object
Constructor Details
#initialize(config_name, metrics, collector_poll_time: 60, thread_pool_size: 2) ⇒ CollectorsPool
Returns a new instance of CollectorsPool.
9 10 11 12 13 14 15 16 17 |
# File 'lib/topological_inventory/providers/common/collectors_pool.rb', line 9 def initialize(config_name, metrics, collector_poll_time: 60, thread_pool_size: 2) self.config_name = config_name self.collector_status = Concurrent::Map.new self.metrics = metrics self.collector_poll_time = collector_poll_time self.secrets = nil self.thread_pool = Concurrent::FixedThreadPool.new(thread_pool_size) self.updated_at = {} end |
Instance Method Details
#run! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/topological_inventory/providers/common/collectors_pool.rb', line 19 def run! loop do reload_config reload_secrets # Secret is deployed just after config map, we should wait for it queue_collectors if secrets_newer_than_config? sleep(5) end end |
#stop! ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/topological_inventory/providers/common/collectors_pool.rb', line 31 def stop! collectors.each_value(&:stop) thread_pool.shutdown # Wait for end of collectors to ensure metrics are stopped after them thread_pool.wait_for_termination end |