Sha256: 029aefcea4ab5df5039279fcce5e2f8cb1c0c4302d4dff01cdb27da44ff3f11d

Contents?: true

Size: 589 Bytes

Versions: 14

Compression:

Stored size: 589 Bytes

Contents

module LitmusPaper
  module Dependency
    class TCP
      def initialize(ip, port, options = {})
        @ip, @port = ip, port
        @timeout = options.fetch(:timeout_seconds, 5)
      end

      def available?
        Timeout.timeout(@timeout) do
          socket = TCPSocket.new(@ip, @port)
          socket.close
        end
        true
      rescue Exception => e
        LitmusPaper.logger.info("TCP available check to #{@ip}:#{@port} failed with #{e.message}")
        false
      end

      def to_s
        "Dependency::TCP(tcp://#{@ip}:#{@port})"
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
litmus_paper-0.8.5 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.8.4 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.8.3 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.8.2 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.8.1 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.8.0 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.7.9 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.7.5 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.7.4 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.7.3 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.7.2 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.7.1 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.7.0 lib/litmus_paper/dependency/tcp.rb
litmus_paper-0.6.3 lib/litmus_paper/dependency/tcp.rb