Class: TwistlockControl::Entities::CompositeService
- Inherits:
-
Service
- Object
- TwistlockControl::Entity
- PersistedEntity
- Service
- TwistlockControl::Entities::CompositeService
- Defined in:
- lib/twistlock_control/entities/composite_service.rb
Overview
A CompositeService is a service that consists of a number of services working together to provide a single service. For example a web forum service might consist of a MySQL service, for persistant storage, and a Ruby HTTP service that serves HTML sites and queries the storage. In the CompositeService you may choose to only expose the HTTP service, making it only possible to query the MySQL database through the Ruby application, which might be considered proper encapsulation.
Relations between services are described by the links attribute. A link is characterized by a producer and a consumer, the consumer will connect to the producers provided service.
Instance Method Summary collapse
Methods inherited from Service
Methods inherited from PersistedEntity
all, deserialize, find_by_id, find_with_ids, inherited, #remove, #repository, #save
Methods inherited from TwistlockControl::Entity
Instance Method Details
#containers ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/twistlock_control/entities/composite_service.rb', line 63 def containers result = [] services = self.services.map(&:service) composites = services.select { |s| s.service_type == :composite } containers = services.select { |s| s.service_type == :container } result += containers composites.each do |c| result += c.containers end result end |
#serialize ⇒ Object
75 76 77 |
# File 'lib/twistlock_control/entities/composite_service.rb', line 75 def serialize super.merge! links: links.map(&:attributes) end |
#services ⇒ Object
59 60 61 |
# File 'lib/twistlock_control/entities/composite_service.rb', line 59 def services Service.find_with_ids(service_relations.values) end |