Class: LogStash::Config::PipelineConfig

Inherits:
Object
  • Object
show all
Includes:
Util::Loggable
Defined in:
lib/logstash/config/pipeline_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, pipeline_id, config_parts, settings) ⇒ PipelineConfig

Returns a new instance of PipelineConfig.



10
11
12
13
14
15
16
17
18
# File 'lib/logstash/config/pipeline_config.rb', line 10

def initialize(source, pipeline_id, config_parts, settings)
  @source = source
  @pipeline_id = pipeline_id
  # We can't use Array() since config_parts may be a java object!
  config_parts_array = config_parts.is_a?(Array) ? config_parts : [config_parts]
  @config_parts = config_parts_array.sort_by { |config_part| [config_part.protocol.to_s, config_part.id] }
  @settings = settings
  @read_at = Time.now
end

Instance Attribute Details

#config_partsObject (readonly)

Returns the value of attribute config_parts.



8
9
10
# File 'lib/logstash/config/pipeline_config.rb', line 8

def config_parts
  @config_parts
end

#pipeline_idObject (readonly)

Returns the value of attribute pipeline_id.



8
9
10
# File 'lib/logstash/config/pipeline_config.rb', line 8

def pipeline_id
  @pipeline_id
end

#read_atObject (readonly)

Returns the value of attribute read_at.



8
9
10
# File 'lib/logstash/config/pipeline_config.rb', line 8

def read_at
  @read_at
end

#settingsObject (readonly)

Returns the value of attribute settings.



8
9
10
# File 'lib/logstash/config/pipeline_config.rb', line 8

def settings
  @settings
end

#sourceObject (readonly)

Returns the value of attribute source.



8
9
10
# File 'lib/logstash/config/pipeline_config.rb', line 8

def source
  @source
end

Instance Method Details

#==(other) ⇒ Object



32
33
34
# File 'lib/logstash/config/pipeline_config.rb', line 32

def ==(other)
  config_hash == other.config_hash && pipeline_id == other.pipeline_id && settings == other.settings
end

#config_hashObject



20
21
22
# File 'lib/logstash/config/pipeline_config.rb', line 20

def config_hash
  @config_hash ||= Digest::SHA1.hexdigest(config_string)
end

#config_stringObject



24
25
26
# File 'lib/logstash/config/pipeline_config.rb', line 24

def config_string
  @config_string = config_parts.collect(&:text).join("\n")
end

#display_debug_informationObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/logstash/config/pipeline_config.rb', line 36

def display_debug_information
  logger.debug("-------- Logstash Config ---------")
  logger.debug("Config from source", :source => source, :pipeline_id => pipeline_id)

  config_parts.each do |config_part|
    logger.debug("Config string", :protocol => config_part.protocol, :id => config_part.id)
    logger.debug("\n\n#{config_part.text}")
  end
  logger.debug("Merged config")
  logger.debug("\n\n#{config_string}")
end

#system?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/logstash/config/pipeline_config.rb', line 28

def system?
  @settings.get("pipeline.system")
end