Class: Anschel::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/anschel/output.rb,
lib/anschel/output/base.rb,
lib/anschel/output/device.rb,
lib/anschel/output/elasticsearch.rb

Defined Under Namespace

Classes: Base, Device, Elasticsearch

Instance Method Summary collapse

Constructor Details

#initialize(config, stats, log) ⇒ Output

Returns a new instance of Output.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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

Instance Method Details

#push(event) ⇒ Object



40
41
42
43
44
# File 'lib/anschel/output.rb', line 40

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

#stopObject



33
34
35
36
37
# File 'lib/anschel/output.rb', line 33

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