Class: LogStash::Compiler
- Inherits:
-
Object
- Object
- LogStash::Compiler
- Includes:
- Util::Loggable
- Defined in:
- lib/logstash/compiler.rb
Class Method Summary collapse
- .compile_graph(source_with_metadata, support_escapes) ⇒ Object
- .compile_imperative(source_with_metadata, support_escapes) ⇒ Object
- .compile_sources(sources_with_metadata, support_escapes) ⇒ Object
Class Method Details
.compile_graph(source_with_metadata, support_escapes) ⇒ Object
48 49 50 |
# File 'lib/logstash/compiler.rb', line 48 def self.compile_graph(, support_escapes) Hash[compile_imperative(, support_escapes).map {|section,icompiled| [section, icompiled.toGraph]}] end |
.compile_imperative(source_with_metadata, support_escapes) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/logstash/compiler.rb', line 32 def self.compile_imperative(, support_escapes) if !.is_a?(org.logstash.common.SourceWithMetadata) raise ArgumentError, "Expected 'org.logstash.common.SourceWithMetadata', got #{.class}" end grammar = LogStashCompilerLSCLGrammarParser.new config = grammar.parse(.text) if config.nil? raise ConfigurationError, grammar.failure_reason end config.process_escape_sequences = support_escapes config.compile() end |
.compile_sources(sources_with_metadata, support_escapes) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/logstash/compiler.rb', line 9 def self.compile_sources(, support_escapes) graph_sections = .map do |swm| self.compile_graph(swm, support_escapes) end input_graph = Graph.combine(*graph_sections.map {|s| s[:input] }).graph output_graph = Graph.combine(*graph_sections.map {|s| s[:output] }).graph filter_graph = graph_sections.reduce(nil) do |acc, s| filter_section = s[:filter] if acc.nil? filter_section else acc.chain(filter_section) end end original_source = .map(&:text).join("\n") PipelineIR.new(input_graph, filter_graph, output_graph, original_source) end |