Class: LogStash::Plugins::HooksRegistry
- Inherits:
- 
      Object
      
        - Object
- LogStash::Plugins::HooksRegistry
 
- Defined in:
- lib/logstash/plugins/hooks_registry.rb
Overview
This calls allow logstash to expose the endpoints for listeners
Instance Method Summary collapse
- #emitters_count ⇒ Object
- #hooks_count(emitter_scope = nil) ⇒ Object
- 
  
    
      #initialize  ⇒ HooksRegistry 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of HooksRegistry. 
- #register_emitter(emitter_scope, dispatcher) ⇒ Object
- #register_hooks(emitter_scope, callback) ⇒ Object
- #remove_emitter(emitter_scope) ⇒ Object
Constructor Details
#initialize ⇒ HooksRegistry
Returns a new instance of HooksRegistry.
| 8 9 10 11 | # File 'lib/logstash/plugins/hooks_registry.rb', line 8 def initialize @registered_emitters = ConcurrentHashMap.new @registered_hooks = ConcurrentHashMap.new end | 
Instance Method Details
#emitters_count ⇒ Object
| 31 32 33 | # File 'lib/logstash/plugins/hooks_registry.rb', line 31 def emitters_count @registered_emitters.size end | 
#hooks_count(emitter_scope = nil) ⇒ Object
| 35 36 37 38 39 40 41 42 | # File 'lib/logstash/plugins/hooks_registry.rb', line 35 def hooks_count(emitter_scope = nil) if emitter_scope.nil? @registered_hooks.elements().collect(&:size).reduce(0, :+) else callbacks = @registered_hooks.get(emitter_scope) callbacks.nil? ? 0 : @registered_hooks.get(emitter_scope).size end end | 
#register_emitter(emitter_scope, dispatcher) ⇒ Object
| 13 14 15 16 | # File 'lib/logstash/plugins/hooks_registry.rb', line 13 def register_emitter(emitter_scope, dispatcher) @registered_emitters.put(emitter_scope, dispatcher) sync_hooks end | 
#register_hooks(emitter_scope, callback) ⇒ Object
| 22 23 24 25 26 27 28 29 | # File 'lib/logstash/plugins/hooks_registry.rb', line 22 def register_hooks(emitter_scope, callback) callbacks = @registered_hooks.computeIfAbsent(emitter_scope) do CopyOnWriteArrayList.new end callbacks.add(callback) sync_hooks end | 
#remove_emitter(emitter_scope) ⇒ Object
| 18 19 20 | # File 'lib/logstash/plugins/hooks_registry.rb', line 18 def remove_emitter(emitter_scope) @registered_emitters.remove(emitter_scope) end |