Sha256: 9ff75e419453a5af513e6ca5c36e2498be98621359ff1929f50b9dc9568ac780

Contents?: true

Size: 470 Bytes

Versions: 5

Compression:

Stored size: 470 Bytes

Contents

# frozen_string_literal: true

require "timeout"

class WaitForSolr < Struct.new(:port, :timeout)
  def self.on(port, timeout, &block)
    new(port, timeout).wait(&block)
  end

  def self.running_on?(port)
    new(port).responding?
  end

  def wait
    Timeout.timeout timeout do
      until responding?
        yield
        sleep 1
      end
    end
  end

  def responding?
    system %(curl -o /dev/null "http://localhost:#{port}/solr" > /dev/null 2>&1)
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
koalagator-3.0.0 lib/wait_for_solr.rb
koalagator-2.1.1 lib/wait_for_solr.rb
koalagator-2.1.0 lib/wait_for_solr.rb
calagator2-2.1.1 lib/wait_for_solr.rb
calagator2-2.1.0 lib/wait_for_solr.rb