Sha256: 841ec5e0558f4005b4970265f3469a6be94ba7f7a624aff08174215f5c2abcf8

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'logstash/environment'

module LogStash; module Util
  class PluginDeadLetterQueueWriter

    attr_reader :plugin_id, :plugin_type, :inner_writer

    def initialize(inner_writer, plugin_id, plugin_type)
      @plugin_id = plugin_id
      @plugin_type = plugin_type
      @inner_writer = inner_writer
    end

    def write(logstash_event, reason)
      if @inner_writer && @inner_writer.is_open
        @inner_writer.writeEntry(logstash_event.to_java, @plugin_type, @plugin_id, reason)
      end
    end

    def close
      if @inner_writer && @inner_writer.is_open
        @inner_writer.close
      end
    end
  end

  class DummyDeadLetterQueueWriter
    # class uses to represent a writer when dead_letter_queue is disabled
    def initialize
    end

    def write(logstash_event, reason)
      # noop
    end

    def is_open
      false
    end

    def close
      # noop
    end
  end

  class DeadLetterQueueFactory
    java_import org.logstash.common.DeadLetterQueueFactory

    def self.get(pipeline_id)
      if LogStash::SETTINGS.get("dead_letter_queue.enable")
        return DeadLetterQueueWriter.new(
          DeadLetterQueueFactory.getWriter(pipeline_id, LogStash::SETTINGS.get("path.dead_letter_queue")))
      else
        return DeadLetterQueueWriter.new(nil)
      end
    end

    def self.close(pipeline_id)
      DeadLetterQueueFactory.close(pipeline_id)
    end
  end
end end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.0-java/lib/logstash/util/dead_letter_queue_manager.rb
logstash-core-5.5.0-java lib/logstash/util/dead_letter_queue_manager.rb
logstash-core-6.0.0.alpha2-java lib/logstash/util/dead_letter_queue_manager.rb