Sha256: 7fde502f163cc54d3da3daf6a0506bc5001b5197dbe6ee538bde514a22788384

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

module Hallmonitor
  class Dispatcher
    @outputters = []

    # Returns list of outputters registered
    # @return [Array<Outputter>]
    def self.outputters
      @outputters
    end

    # Adds an outputter.  Outputters are required to respond to :process
    # @param outputter [Object]
    # @see Hallmonitor::Outputters::StatsdOutputter
    def self.add_outputter(outputter)
      @outputters << outputter if outputter.respond_to?(:process)
    end

    # Removes all outputters
    def self.clear_outputters
      @outputters = []
    end

    # Outputs an event via each registered outputter.
    # If {Hallmonitor::Configuration} has the option
    # `trap_outputter_exceptions` set to `true` then this method
    # will trap and squash any errors raised by the outputter.
    # @param event [Event] The event to output
    # @return nil
    def self.output(event)
      @outputters.each do |o|
        begin
          o.process(event)
        rescue
          raise unless Hallmonitor.config && Hallmonitor.config.trap_outputter_exceptions
        end
      end
      nil
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hallmonitor-5.2.0 lib/hallmonitor/dispatcher.rb
hallmonitor-5.1.0 lib/hallmonitor/dispatcher.rb
hallmonitor-5.0.0 lib/hallmonitor/dispatcher.rb
hallmonitor-4.2.0 lib/hallmonitor/dispatcher.rb
hallmonitor-4.1.0 lib/hallmonitor/dispatcher.rb
hallmonitor-4.0.0 lib/hallmonitor/dispatcher.rb
hallmonitor-3.0.0 lib/hallmonitor/dispatcher.rb
hallmonitor-2.0.0 lib/hallmonitor/dispatcher.rb