Class: Nonnative::Ports

Inherits:
Object
  • Object
show all
Defined in:
lib/nonnative/ports.rb

Overview

Performs aggregate TCP readiness/shutdown checks for all configured runner ports.

A runner is considered ready only when every configured port is open, and stopped only when every configured port is closed.

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(runner) ⇒ Ports

Returns a new instance of Ports.

Parameters:

  • runner (#host, #ports, #timeout)

    runner configuration providing connection details



12
13
14
15
16
# File 'lib/nonnative/ports.rb', line 12

def initialize(runner)
  @runner = runner
  @ports = runner.ports.map { |port| Nonnative::Port.new(runner, port) }
  @readiness = Nonnative::HTTPProbe.new(runner) if runner.respond_to?(:readiness) && runner.readiness
end

Instance Method Details

#closed?Boolean

Returns whether all configured ports become non-connectable before their timeouts elapse.

Returns:

  • (Boolean)


28
29
30
# File 'lib/nonnative/ports.rb', line 28

def closed?
  ports.all?(&:closed?)
end

#descriptionString

Returns endpoint and log context for lifecycle errors.

Returns:

  • (String)


42
43
44
45
46
47
48
49
# File 'lib/nonnative/ports.rb', line 42

def description
  details = []
  details << "readiness: #{readiness.endpoint}" if readiness
  log = runner.log if runner.respond_to?(:log)
  details << "log: #{log}" if log

  details.empty? ? endpoints : "#{endpoints} (#{details.join('; ')})"
end

#endpointsString

Returns the checked endpoints for lifecycle diagnostics.

Returns:

  • (String)


35
36
37
# File 'lib/nonnative/ports.rb', line 35

def endpoints
  ports.map(&:endpoint).join(', ')
end

#open?Boolean

Returns whether all configured ports become connectable before their timeouts elapse.

Returns:

  • (Boolean)


21
22
23
# File 'lib/nonnative/ports.rb', line 21

def open?
  ports.all?(&:open?) && (readiness.nil? || readiness.ready?)
end