class Dendrite::Generators::Synapse
Constants
- ServiceConfig
Attributes
read_only[R]
Public Class Methods
new(graph:, service_names:, environment: :dev)
click to toggle source
Calls superclass method
Dendrite::Generators::Base::new
# 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
Public Instance Methods
to_h()
click to toggle source
# File lib/dendrite/generators/synapse.rb, line 32 def to_h service_list = services.inject({}) do |hash, service| if read_only[service.name] data = service.to_h discovery_data = data[:discovery].merge({ path: "/smartstack/services/#{service.organization}/#{service.component}/#{service.service.real_name}_readonly/instances" }) data[:discovery] = discovery_data hash[service.name] = data else hash[service.name] = service.to_h end hash end { haproxy: Dendrite::Config.global_haproxy_config, file_output: { output_directory: '/tmp/synapse.config' } }.merge({services: service_list}) end