Class: Nonnative::Ports
- Inherits:
-
Object
- Object
- Nonnative::Ports
- 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.
Instance Method Summary collapse
-
#closed? ⇒ Boolean
Returns whether all configured ports become non-connectable before their timeouts elapse.
-
#description ⇒ String
Returns endpoint and log context for lifecycle errors.
-
#endpoints ⇒ String
Returns the checked endpoints for lifecycle diagnostics.
-
#initialize(runner) ⇒ Ports
constructor
A new instance of Ports.
-
#open? ⇒ Boolean
Returns whether all configured ports become connectable before their timeouts elapse.
Constructor Details
#initialize(runner) ⇒ Ports
Returns a new instance of Ports.
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.
28 29 30 |
# File 'lib/nonnative/ports.rb', line 28 def closed? ports.all?(&:closed?) end |
#description ⇒ String
Returns endpoint and log context for lifecycle errors.
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 |
#endpoints ⇒ String
Returns the checked endpoints for lifecycle diagnostics.
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.
21 22 23 |
# File 'lib/nonnative/ports.rb', line 21 def open? ports.all?(&:open?) && (readiness.nil? || readiness.ready?) end |