Class: LogStash::Compiler
- Inherits:
-
Object
- Object
- LogStash::Compiler
show all
- Includes:
- Util::Loggable
- Defined in:
- lib/logstash/compiler.rb
Class Method Summary
collapse
included, #logger, #slow_logger
Class Method Details
.compile_graph(source_with_metadata, support_escapes) ⇒ Object
49
50
51
|
# File 'lib/logstash/compiler.rb', line 49
def self.compile_graph(source_with_metadata, support_escapes)
Hash[compile_imperative(source_with_metadata, support_escapes).map {|section,icompiled| [section, icompiled.toGraph]}]
end
|
.compile_imperative(source_with_metadata, support_escapes) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/logstash/compiler.rb', line 33
def self.compile_imperative(source_with_metadata, support_escapes)
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 = support_escapes
config.compile(source_with_metadata)
end
|
.compile_sources(sources_with_metadata, support_escapes) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/logstash/compiler.rb', line 10
def self.compile_sources(sources_with_metadata, support_escapes)
graph_sections = sources_with_metadata.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 = sources_with_metadata.map(&:text).join("\n")
PipelineIR.new(input_graph, filter_graph, output_graph, original_source)
end
|