Sha256: 5ccba827d52d2442a8db4f3a0b63bb09e430b064eaec8d5c0606badeee06e98c

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'logstash/util/loggable'
require 'logstash/compiler/lscl/lscl_grammar'

java_import org.logstash.config.ir.Pipeline
java_import org.logstash.config.ir.graph.Graph;
java_import org.logstash.config.ir.graph.PluginVertex;

module LogStash; class Compiler
  include ::LogStash::Util::Loggable

  def self.compile_pipeline(config_str, source_file=nil)
    graph_sections = self.compile_graph(config_str, source_file)
    pipeline = org.logstash.config.ir.Pipeline.new(
      graph_sections[:input],
      graph_sections[:filter],
      graph_sections[:output]
    )
  end

  def self.compile_ast(config_str, source_file=nil)
    grammar = LogStashCompilerLSCLGrammarParser.new
    config = grammar.parse(config_str)

    if config.nil?
      raise ConfigurationError, grammar.failure_reason
    end

    config
  end

  def self.compile_imperative(config_str, source_file=nil)
    compile_ast(config_str, source_file).compile(source_file)
  end

  def self.compile_graph(config_str, source_file=nil)
    Hash[compile_imperative(config_str, source_file).map {|section,icompiled| [section, icompiled.toGraph]}]
  end
end; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-core-6.0.0.alpha1-java lib/logstash/compiler.rb