class Anschel::Output

Public Class Methods

new(config, stats, log) click to toggle source
# File lib/anschel/output.rb, line 7
def initialize config, stats, log
  log.info event: 'output-loading'
  log.info 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.info event: 'output-loaded', kind: 'device'
    when 'elasticsearch'
      @outputs << Output::Elasticsearch.new(output, stats, log)
      log.info event: 'output-loaded', kind: 'elasticsearch'
    else
      raise 'Unkown output type'
    end
  end

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

Public Instance Methods

push(event) click to toggle source
# File lib/anschel/output.rb, line 40
def push event
  @outputs.each do |output|
    output.push event
  end
end
stop() click to toggle source
# File lib/anschel/output.rb, line 33
def stop
  return if @stopped
  @outputs.map &:stop
  @stopped = true
end