Class: Fluent::ConfigExpanderInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_config_expander.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pluginObject

Returns the value of attribute plugin.



12
13
14
# File 'lib/fluent/plugin/in_config_expander.rb', line 12

def plugin
  @plugin
end

Instance Method Details

#builtin_mappingObject



19
20
21
# File 'lib/fluent/plugin/in_config_expander.rb', line 19

def builtin_mapping
  {'__hostname__' => @hostname, '__HOSTNAME__' => @hostname, '${hostname}' => @hostname, '${HOSTNAME}' => @hostname}
end

#configure(conf) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fluent/plugin/in_config_expander.rb', line 30

def configure(conf)
  super
  
  configs = conf.elements.select{|e| e.name == 'config'}
  if configs.size != 1
    raise Fluent::ConfigError, "config_expander needs just one <config> ... </config> section"
  end
  ex = expand_config(configs.first)
  @plugin = Fluent::Plugin.new_input(ex['type'])
  @plugin.configure(ex)

  mark_used(configs.first)
end

#expand_config(conf) ⇒ Object



23
24
25
26
27
28
# File 'lib/fluent/plugin/in_config_expander.rb', line 23

def expand_config(conf)
  ex = Fluent::Config::Expander.expand(conf, builtin_mapping())
  ex.name = ''
  ex.arg = ''
  ex
end

#mark_used(conf) ⇒ Object



14
15
16
17
# File 'lib/fluent/plugin/in_config_expander.rb', line 14

def mark_used(conf)
  conf.keys.each {|key| conf[key] } # to suppress unread configuration warning
  conf.elements.each{|e| mark_used(e)}
end

#shutdownObject



48
49
50
# File 'lib/fluent/plugin/in_config_expander.rb', line 48

def shutdown
  @plugin.shutdown
end

#startObject



44
45
46
# File 'lib/fluent/plugin/in_config_expander.rb', line 44

def start
  @plugin.start
end