Class: Nonnative::ConfigurationService

Inherits:
ConfigurationRunner show all
Defined in:
lib/nonnative/configuration_service.rb

Overview

Service-specific configuration.

A "service" is proxy-only: it does not start a Ruby thread or OS process. It exists so Nonnative can start and control a proxy in front of an external dependency.

Instances are usually created through Nonnative::Configuration#service.

Constant Summary

Constants inherited from ConfigurationRunner

Nonnative::ConfigurationRunner::DEFAULT_TIMEOUT

Instance Attribute Summary collapse

Attributes inherited from ConfigurationRunner

#host, #name, #wait

Instance Method Summary collapse

Constructor Details

#initializevoid

Creates a service configuration with defaults.



31
32
33
34
35
36
37
38
# File 'lib/nonnative/configuration_service.rb', line 31

def initialize
  super

  self.port = 0
  self.timeout = DEFAULT_TIMEOUT
  @readiness = []
  @proxy = Nonnative::ConfigurationProxy.new
end

Instance Attribute Details

#portInteger

Returns client-facing port used by the service proxy.

Returns:

  • (Integer)

    client-facing port used by the service proxy



15
16
17
# File 'lib/nonnative/configuration_service.rb', line 15

def port
  @port
end

#proxyNonnative::ConfigurationProxy

Proxy configuration for this service.



23
24
25
# File 'lib/nonnative/configuration_service.rb', line 23

def proxy
  @proxy
end

#readinessArray<Nonnative::ConfigurationServiceReadiness>

Returns optional service readiness checks.

Returns:



26
27
28
# File 'lib/nonnative/configuration_service.rb', line 26

def readiness
  @readiness
end

#timeoutNumeric

Returns readiness timeout (seconds) used when waiting for service readiness.

Returns:

  • (Numeric)

    readiness timeout (seconds) used when waiting for service readiness



18
19
20
# File 'lib/nonnative/configuration_service.rb', line 18

def timeout
  @timeout
end

Instance Method Details

#portsvoid

This method returns an undefined value.

Services expose a single proxy listener, so plural runner ports are not supported.

Raises:

  • (ArgumentError)

    when plural service ports are read



74
75
76
# File 'lib/nonnative/configuration_service.rb', line 74

def ports
  raise ArgumentError, "Use 'port' instead of 'ports' for service '#{name}'"
end

#ports=(_value) ⇒ void

This method returns an undefined value.

Services expose a single proxy listener, so plural runner ports are not supported.

Parameters:

  • _value (Array<Integer>)

    ignored plural ports

Raises:

  • (ArgumentError)

    when plural service ports are assigned



83
84
85
# File 'lib/nonnative/configuration_service.rb', line 83

def ports=(_value)
  raise ArgumentError, "Use 'port' instead of 'ports' for service '#{name}'"
end