Class: Falcon::Service::Generic
- Inherits:
-
Object
- Object
- Falcon::Service::Generic
- Defined in:
- lib/falcon/service/generic.rb
Overview
Captures the stateful behaviour of a specific service. Specifies the interfaces required by derived classes.
Designed to be invoked within an Async::Controller::Container.
Direct Known Subclasses
Class Method Summary collapse
-
.wrap(environment) ⇒ Object
Convert the given environment into a service if possible.
Instance Method Summary collapse
-
#include?(keys) ⇒ Boolean
Whether the service environment contains the specified keys.
-
#initialize(environment) ⇒ Generic
constructor
Initialize the service from the given environment.
-
#logger ⇒ Object
The logger to use for this service.
-
#name ⇒ Object
The name of the service.
-
#setup(container) ⇒ Object
Setup the service into the specified container.
-
#start ⇒ Object
Start the service.
-
#stop ⇒ Object
Stop the service.
Constructor Details
#initialize(environment) ⇒ Generic
Initialize the service from the given environment.
41 42 43 44 |
# File 'lib/falcon/service/generic.rb', line 41 def initialize(environment) @environment = environment @evaluator = @environment.evaluator end |
Class Method Details
.wrap(environment) ⇒ Object
Convert the given environment into a service if possible.
32 33 34 35 36 37 |
# File 'lib/falcon/service/generic.rb', line 32 def self.wrap(environment) evaluator = environment.evaluator service = evaluator.service || self return service.new(environment) end |
Instance Method Details
#include?(keys) ⇒ Boolean
Whether the service environment contains the specified keys. This is used for matching environment configuration to service behaviour.
48 49 50 |
# File 'lib/falcon/service/generic.rb', line 48 def include?(keys) keys.all?{|key| @environment.include?(key)} end |
#logger ⇒ Object
The logger to use for this service.
60 61 62 |
# File 'lib/falcon/service/generic.rb', line 60 def logger return Console.logger # .with(name: name) end |
#name ⇒ Object
The name of the service. e.g. `myapp.com`.
54 55 56 |
# File 'lib/falcon/service/generic.rb', line 54 def name @evaluator.name end |
#setup(container) ⇒ Object
Setup the service into the specified container.
70 71 |
# File 'lib/falcon/service/generic.rb', line 70 def setup(container) end |
#start ⇒ Object
Start the service.
65 66 |
# File 'lib/falcon/service/generic.rb', line 65 def start end |
#stop ⇒ Object
Stop the service.
74 75 |
# File 'lib/falcon/service/generic.rb', line 74 def stop end |