Class: LogStash::Config::AST::Branch
- Defined in:
- lib/logstash/config/config_ast.rb
Constant Summary
Constants included from LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers
LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers::AND_METHOD, LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers::BOOLEAN_DSL_METHOD_SIGNATURE, LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers::NAND_METHOD, LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers::OR_METHOD, LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers::XOR_METHOD
Instance Method Summary collapse
Methods inherited from Node
Methods included from LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers
#base_id, #base_protocol, #base_source_with_metadata, #base_source_with_metadata=, #compose, #compose_for, #jdsl, jdsl, #line_and_column, #source_meta
Instance Method Details
#compile ⇒ Object
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/logstash/config/config_ast.rb', line 353 def compile # this construct is non obvious. we need to loop through each event and apply the conditional. # each branch of a conditional will contain a construct (a filter for example) that also loops through # the events variable so we have to initialize it to [event] for the branch code. # at the end, events is returned to handle the case where no branch match and no branch code is executed # so we must make sure to return the current event. type = recursive_select_parent(PluginSection).first.plugin_type.text_value if type == "filter" i = LogStash::Config::AST.deferred_conditionals_index += 1 source = <<-CODE @generated_objects[:cond_func_#{i}] = lambda do |input_events| result = [] input_events.each do |event| events = [event] #{super} end result += events end result end CODE LogStash::Config::AST.deferred_conditionals << source <<-CODE events = @generated_objects[:cond_func_#{i}].call(events) CODE else # Output <<-CODE #{super} end CODE end end |