Class: Fluent::Plugin::ConfigExpanderFilter
- Inherits:
-
Filter
- Object
- Filter
- Fluent::Plugin::ConfigExpanderFilter
- Defined in:
- lib/fluent/plugin/filter_config_expander.rb
Instance Method Summary collapse
- #builtin_mapping ⇒ Object
- #configure(conf) ⇒ Object
- #expand_config(conf) ⇒ Object
- #mark_used(conf) ⇒ Object
Instance Method Details
#builtin_mapping ⇒ Object
20 21 22 |
# File 'lib/fluent/plugin/filter_config_expander.rb', line 20 def builtin_mapping {'__hostname__' => @hostname, '__HOSTNAME__' => @hostname, '${hostname}' => @hostname, '${HOSTNAME}' => @hostname} end |
#configure(conf) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fluent/plugin/filter_config_expander.rb', line 31 def configure(conf) super ex = (@config_config.corresponding_config_element) type = ex['@type'] @plugin = Fluent::Plugin.new_input(type) @plugin.context_router = self.event_emitter_router(conf['@label']) @plugin.configure(ex) mark_used(@config_config.corresponding_config_element) # hack for https://bugs.ruby-lang.org/issues/12478 in ruby 2.3 or earlier mojule = Module.new do def method_defined?(accessor) methods.include?(accessor.to_sym) end def private_method_defined?(accessor) private_methods.include?(accessor.to_sym) end end self.extend(mojule) unless self.class === Module self.extend SingleForwardable override_methods = @plugin.methods - SingleForwardable.instance_methods - Object.instance_methods def_single_delegators(:@plugin, *override_methods) end |
#expand_config(conf) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/fluent/plugin/filter_config_expander.rb', line 24 def (conf) ex = Fluent::Config::Expander.(conf, builtin_mapping()) ex.name = 'filter' # name/arg will be ignored by Plugin#configure, but anyway ex.arg = conf.arg ex end |
#mark_used(conf) ⇒ Object
15 16 17 18 |
# File 'lib/fluent/plugin/filter_config_expander.rb', line 15 def mark_used(conf) conf.keys.each {|key| conf[key] } # to suppress unread configuration warning conf.elements.each{|e| mark_used(e)} end |