Sha256: c47336d71a19ebce5d6f3b6899747e5c7b2906b2aeb17fcf4e161f0445480394
Contents?: true
Size: 1.75 KB
Versions: 6
Compression:
Stored size: 1.75 KB
Contents
require 'logstash/util/loggable' require 'logstash/compiler/lscl/lscl_grammar' java_import org.logstash.config.ir.PipelineIR java_import org.logstash.config.ir.graph.Graph module LogStash; class Compiler include ::LogStash::Util::Loggable def self.compile_sources(sources_with_metadata, settings) graph_sections = sources_with_metadata.map do |swm| self.compile_graph(swm, settings) 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 = sources_with_metadata.map(&:text).join("\n") PipelineIR.new(input_graph, filter_graph, output_graph, original_source) end def self.compile_ast(source_with_metadata, settings) if !source_with_metadata.is_a?(org.logstash.common.SourceWithMetadata) raise ArgumentError, "Expected 'org.logstash.common.SourceWithMetadata', got #{source_with_metadata.class}" end grammar = LogStashCompilerLSCLGrammarParser.new config = grammar.parse(source_with_metadata.text) if config.nil? raise ConfigurationError, grammar.failure_reason end config.process_escape_sequences = settings.get_value("config.support_escapes") config.compile(source_with_metadata) end def self.compile_imperative(source_with_metadata, settings) compile_ast(source_with_metadata, settings) end def self.compile_graph(source_with_metadata, settings) Hash[compile_imperative(source_with_metadata, settings).map {|section,icompiled| [section, icompiled.toGraph]}] end end; end
Version data entries
6 entries across 6 versions & 1 rubygems