Sha256: 3a72069ed6f20e3afeaefcc48be9a3389783102c2ac8bac65386789f0fce258b

Contents?: true

Size: 1009 Bytes

Versions: 13

Compression:

Stored size: 1009 Bytes

Contents

require_relative 'output/elasticsearch'
require_relative 'output/device'


module Anschel
  class Output
    def initialize config, stats, log
      log.info event: 'output-loading'
      log.debug event: 'output-config', config: config

      @outputs = []

      stats.create 'output'
      stats.get 'output'

      config.each do |output|
        case output.delete(:kind)
        when 'device'
          @outputs << Output::Device.new(output, stats, log)
          log.trace event: 'output-loaded', kind: 'device'
        when 'elasticsearch'
          @outputs << Output::Elasticsearch.new(output, stats, log)
          log.trace event: 'output-loaded', kind: 'elasticsearch'
        else
          raise 'Unkown output type'
        end
      end

      log.info event: 'output-fully-loaded'
    end


    def stop
      return if @stopped
      @outputs.map &:stop
      @stopped = true
    end


    def push event
      @outputs.each do |output|
        output.push event
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
anschel-0.7.12 lib/anschel/output.rb
anschel-0.7.11 lib/anschel/output.rb
anschel-0.7.10 lib/anschel/output.rb
anschel-0.7.9 lib/anschel/output.rb
anschel-0.7.8 lib/anschel/output.rb
anschel-0.7.7 lib/anschel/output.rb
anschel-0.7.6 lib/anschel/output.rb
anschel-0.7.5 lib/anschel/output.rb
anschel-0.7.4 lib/anschel/output.rb
anschel-0.7.3 lib/anschel/output.rb
anschel-0.7.2 lib/anschel/output.rb
anschel-0.7.1 lib/anschel/output.rb
anschel-0.7.0 lib/anschel/output.rb