Sha256: 7a3405b87344c19f0eeb0ff425981d3612e0987dbf6aa463fec5b852fb2b36a5

Contents?: true

Size: 1.65 KB

Versions: 3

Compression:

Stored size: 1.65 KB

Contents

if Gem.loaded_specs['elasticsearch-transport'].version >= Gem::Version.new("7.2.0")
  # elasticsearch-transport versions prior to 7.2.0 suffered of a race condition on accessing
  # the connection pool. This issue was fixed with https://github.com/elastic/elasticsearch-ruby/commit/15f9d78591a6e8823948494d94b15b0ca38819d1
   # This plugin, at the moment, is forced to use v5.x so we have to monkey patch the gem. When this requirement
   # ceases, this patch could be removed.
  puts "WARN remove the patch code into logstash-input-elasticsearch plugin"
else
  module Elasticsearch
    module Transport
      module Transport
        module Connections
          module Selector

            # "Round-robin" selector strategy (default).
            #
            class RoundRobin
              include Base

              # @option arguments [Connections::Collection] :connections Collection with connections.
              #
              def initialize(arguments = {})
                super
                @mutex = Mutex.new
                @current = nil
              end

              # Returns the next connection from the collection, rotating them in round-robin fashion.
              #
              # @return [Connections::Connection]
              #
              def select(options={})
                @mutex.synchronize do
                  conns = connections
                  if @current && (@current < conns.size-1)
                    @current += 1
                  else
                    @current = 0
                  end
                  conns[@current]
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logstash-input-elasticsearch-4.9.1 lib/logstash/inputs/patch.rb
logstash-input-elasticsearch-4.9.0 lib/logstash/inputs/patch.rb
logstash-input-elasticsearch-4.8.1 lib/logstash/inputs/patch.rb