class TwistlockControl::Entities::CompositeService
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.
Public Instance Methods
containers()
click to toggle source
# 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()
click to toggle source
Calls superclass method
# File lib/twistlock_control/entities/composite_service.rb, line 75 def serialize super.merge! links: links.map(&:attributes) end
services()
click to toggle source
# File lib/twistlock_control/entities/composite_service.rb, line 59 def services Service.find_with_ids(service_relations.values) end
Private Instance Methods
generate_id()
click to toggle source
# File lib/twistlock_control/entities/composite_service.rb, line 81 def generate_id name.downcase.gsub(' ', '-') end