Class: Prefab::LogPathAggregator
- Inherits:
-
Object
- Object
- Prefab::LogPathAggregator
- Includes:
- PeriodicSync
- Defined in:
- lib/prefab/log_path_aggregator.rb
Constant Summary collapse
- LOG =
Prefab::InternalLogger.new(LogPathAggregator)
- INCREMENT =
->(count) { (count || 0) + 1 }
- SEVERITY_KEY =
{ ::Logger::DEBUG => 'debugs', ::Logger::INFO => 'infos', ::Logger::WARN => 'warns', ::Logger::ERROR => 'errors', ::Logger::FATAL => 'fatals' }.freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(client:, max_paths:, sync_interval:) ⇒ LogPathAggregator
constructor
A new instance of LogPathAggregator.
- #push(path, severity) ⇒ Object
Methods included from PeriodicSync
#on_prepare_data, #pool, #post, #prepare_data, #start_periodic_sync, #sync
Constructor Details
#initialize(client:, max_paths:, sync_interval:) ⇒ LogPathAggregator
Returns a new instance of LogPathAggregator.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/prefab/log_path_aggregator.rb', line 23 def initialize(client:, max_paths:, sync_interval:) @max_paths = max_paths @client = client @name = 'log_path_aggregator' @data = Concurrent::Map.new @last_data_sent = nil @last_request = nil start_periodic_sync(sync_interval) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
21 22 23 |
# File 'lib/prefab/log_path_aggregator.rb', line 21 def data @data end |
Instance Method Details
#push(path, severity) ⇒ Object
36 37 38 39 40 |
# File 'lib/prefab/log_path_aggregator.rb', line 36 def push(path, severity) return if @data.size >= @max_paths @data.compute([path, severity], &INCREMENT) end |