Method: Dendrite::Generators::Synapse#initialize
- Defined in:
- lib/dendrite/generators/synapse.rb
#initialize(graph:, service_names:, environment: :dev) ⇒ Synapse
Returns a new instance of Synapse.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dendrite/generators/synapse.rb', line 5 def initialize(graph:, service_names:, environment: :dev) super(graph: graph, service_names: service_names) dep = [] read_only = {} @services.each do |service| service.dependencies.each do |_, dependency| dep << dependency.service if read_only.keys.include?(dependency.service.name) if read_only[dependency.service.name] != dependency.read_only raise "Trying to add r/o and r/w for same service" end else read_only[dependency.service.name] = dependency.read_only end end end @read_only = read_only @services = dep.uniq @services.group_by { |service| service.loadbalancer_port }.each do |port, services| if services.length > 1 raise PortCollision, "Port collission between #{services.collect(&:name).join(',')}" end end @services = @services.collect { |service| ServiceConfig.new(service, environment)} end |