Sha256: 77f738db8c0b65543c912bbc9b4d77b69dd94ad860e692310b40b6bc4c9e20aa

Contents?: true

Size: 1.47 KB

Versions: 79

Compression:

Stored size: 1.47 KB

Contents

# encoding: utf-8
require "digest"

module LogStash module Config
  class PipelineConfig
    include LogStash::Util::Loggable

    attr_reader :source, :pipeline_id, :config_parts, :settings, :read_at

    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

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

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

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

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

    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
  end
end end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
logstash-core-6.8.23-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.22-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.21-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.20-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.19-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.18-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.17-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.16-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.15-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.14-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.13-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.12-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.11-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.10-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.9-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.8-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.7-java lib/logstash/config/pipeline_config.rb
logstash-core-7.5.2-java lib/logstash/config/pipeline_config.rb
logstash-core-7.5.1-java lib/logstash/config/pipeline_config.rb
logstash-core-6.8.6-java lib/logstash/config/pipeline_config.rb