Sha256: a8ffee1c75770c458b24c957d86ea27eeb3dfea077480337305dcf68e5915e28

Contents?: true

Size: 717 Bytes

Versions: 1

Compression:

Stored size: 717 Bytes

Contents

require_relative 'expander'

class Fluent::ConfigExpanderInput < Fluent::Input
  Fluent::Plugin.register_input('config_expander', self)

  attr_accessor :plugin

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

  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)
  end

  def start
    @plugin.start
  end

  def shutdown
    @plugin.shutdown
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-config-expander-0.0.1 lib/fluent/plugin/in_config_expander.rb