Class: Nonnative::Service
Overview
Runtime runner for an external dependency.
A service runner does not manage an OS process or Ruby thread. It exists so Nonnative can manage a proxy lifecycle (start/stop/reset) for an external service that is managed elsewhere (for example a database running in Docker).
The underlying configuration is a ConfigurationService.
Instance Attribute Summary collapse
-
#proxy ⇒ Nonnative::Proxy
readonly
Returns the proxy instance for this service.
Instance Method Summary collapse
-
#initialize(service) ⇒ Service
constructor
A new instance of Service.
-
#readiness ⇒ Array<Nonnative::ConfigurationServiceReadiness>
Returns configured service readiness checks.
-
#start ⇒ void
Starts the configured proxy (if any).
-
#stop ⇒ void
Stops the configured proxy (if any).
-
#timeout ⇒ Numeric
Returns the configured service readiness timeout.
Methods inherited from Runner
Constructor Details
#initialize(service) ⇒ Service
Returns a new instance of Service.
21 22 23 24 25 |
# File 'lib/nonnative/service.rb', line 21 def initialize(service) super @proxy = Nonnative::ProxyFactory.create(service) end |
Instance Attribute Details
#proxy ⇒ Nonnative::Proxy (readonly)
Returns the proxy instance for this service.
18 19 20 |
# File 'lib/nonnative/service.rb', line 18 def proxy @proxy end |
Instance Method Details
#readiness ⇒ Array<Nonnative::ConfigurationServiceReadiness>
Returns configured service readiness checks.
30 31 32 |
# File 'lib/nonnative/service.rb', line 30 def readiness service.readiness end |
#start ⇒ void
This method returns an undefined value.
Starts the configured proxy (if any).
44 45 46 47 48 |
# File 'lib/nonnative/service.rb', line 44 def start proxy.start Nonnative.logger.info "started service '#{service.name}'" end |
#stop ⇒ void
This method returns an undefined value.
Stops the configured proxy (if any).
53 54 55 56 57 |
# File 'lib/nonnative/service.rb', line 53 def stop proxy.stop Nonnative.logger.info "stopped service '#{service.name}'" end |
#timeout ⇒ Numeric
Returns the configured service readiness timeout.
37 38 39 |
# File 'lib/nonnative/service.rb', line 37 def timeout service.timeout end |