Class: Nonnative::Service

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

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

Instance Method Summary collapse

Methods inherited from Runner

#name

Constructor Details

#initialize(service) ⇒ Service

Returns a new instance of Service.

Parameters:



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

#proxyNonnative::Proxy (readonly)

Returns the proxy instance for this service.

Returns:



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

def proxy
  @proxy
end

Instance Method Details

#startvoid

This method returns an undefined value.

Starts the configured proxy (if any).



30
31
32
33
34
# File 'lib/nonnative/service.rb', line 30

def start
  proxy.start

  Nonnative.logger.info "started service '#{service.name}'"
end

#stopvoid

This method returns an undefined value.

Stops the configured proxy (if any).



39
40
41
42
43
# File 'lib/nonnative/service.rb', line 39

def stop
  proxy.stop

  Nonnative.logger.info "stopped service '#{service.name}'"
end