Sha256: 2e96ca1719cd4715dc8ba6e7337958336e0857292721f83debd831f4f2af00da
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
require 'fluent/plugin/bare_output' require_relative 'expander' require 'forwardable' require 'socket' class Fluent::Plugin::ConfigExpanderOutput < Fluent::Plugin::BareOutput Fluent::Plugin.register_output('config_expander', self) helpers :event_emitter config_param :hostname, :string, default: Socket.gethostname config_section :config, multi: false, required: true, param_name: :config_config do # to raise configuration error for missing section end def mark_used(conf) conf.keys.each {|key| conf[key] } # to suppress unread configuration warning conf.elements.each{|e| mark_used(e)} end def builtin_mapping {'__hostname__' => @hostname, '__HOSTNAME__' => @hostname, '${hostname}' => @hostname, '${HOSTNAME}' => @hostname} end def expand_config(conf) ex = Fluent::Config::Expander.expand(conf, builtin_mapping()) ex.name = 'match' # name/arg will be ignored by Plugin#configure, but anyway ex.arg = conf.arg ex end def configure(conf) super ex = expand_config(@config_config.corresponding_config_element) type = ex['@type'] @plugin = Fluent::Plugin.new_output(type) @plugin.context_router = self.event_emitter_router(conf['@label']) @plugin.configure(ex) mark_used(@config_config.corresponding_config_element) self.extend SingleForwardable override_methods = self.methods + @plugin.methods - SingleForwardable.instance_methods - Object.instance_methods override_methods.uniq! def_delegators(:@plugin, *override_methods) end def method_missing(name, *args, &block) @plugin.__send__(name, *args, &block) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-config-expander-1.0.0 | lib/fluent/plugin/out_config_expander.rb |