Sha256: 32f20ceae79f257bd8820729bdc72daf8970515a1ae84ebc046e9f843f61a89c

Contents?: true

Size: 1.38 KB

Versions: 47

Compression:

Stored size: 1.38 KB

Contents

# encoding: utf-8
module LogStash
  # In the beginning I was using this code as a method in the Agent class directly
  # But with the plugins system I think we should be able to swap what kind of action would be run.
  #
  # Lets take the example of dynamic source, where the pipeline config and settings are located and
  # managed outside of the machine.
  class StateResolver
    def initialize(metric)
      @metric = metric
    end

    def resolve(pipelines_registry, pipeline_configs)
      actions = []

      pipeline_configs.each do |pipeline_config|
        pipeline = pipelines_registry.get_pipeline(pipeline_config.pipeline_id)

        if pipeline.nil?
          actions << LogStash::PipelineAction::Create.new(pipeline_config, @metric)
        else
          if pipeline_config != pipeline.pipeline_config
            actions << LogStash::PipelineAction::Reload.new(pipeline_config, @metric)
          end
        end
      end

      configured_pipelines = pipeline_configs.collect(&:pipeline_id)

      # If one of the running pipeline is not in the pipeline_configs, we assume that we need to
      # stop it.
      pipelines_registry.running_pipelines.keys
        .select { |pipeline_id| !configured_pipelines.include?(pipeline_id) }
        .each { |pipeline_id| actions << LogStash::PipelineAction::Stop.new(pipeline_id) }

      actions.sort # See logstash/pipeline_action.rb
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

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