Class: DEVp2p::BaseService
- Inherits:
-
Object
- Object
- DEVp2p::BaseService
- Extended by:
- Configurable
- Includes:
- Celluloid, Control
- Defined in:
- lib/devp2p/base_service.rb
Overview
Service instances are added to the application under
app.services.<service_name>.
App should be passed to the service in order to query other services.
Services must be an actor. If a service spawns additional services, it's responsible to stop them.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Class Method Summary collapse
-
.register_with_app(app) ⇒ Object
Services know best how to initiate themselves.
Instance Method Summary collapse
-
#initialize(app) ⇒ BaseService
constructor
A new instance of BaseService.
- #to_s ⇒ Object (also: #inspect)
Methods included from Configurable
Methods included from Control
#initialize_control, #killed?, #run, #start, #stop, #stopped?
Constructor Details
#initialize(app) ⇒ BaseService
Returns a new instance of BaseService.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/devp2p/base_service.rb', line 37 def initialize(app) @app = app @config = Utils.update_config_with_defaults app.config, default_config initialize_control available_services = app.services.each_value.map(&:class) required_services.each do |r| raise MissingRequiredServiceError, "require service #{r}" unless available_services.include?(r) end end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
35 36 37 |
# File 'lib/devp2p/base_service.rb', line 35 def app @app end |
Class Method Details
.register_with_app(app) ⇒ Object
Services know best how to initiate themselves. Create a service
instance, probably based on app.config and app.services.
30 31 32 |
# File 'lib/devp2p/base_service.rb', line 30 def register_with_app(app) app.register_service self, app end |
Instance Method Details
#to_s ⇒ Object Also known as: inspect
49 50 51 |
# File 'lib/devp2p/base_service.rb', line 49 def to_s "<Service #{name}##{object_id}>" end |