class Dendrite::Generators::Nerve

Constants

DEFAULT_PORT

We use this for batch jobs so they can register

ServiceConfig

Public Class Methods

new(graph:, service_names:) click to toggle source
Calls superclass method Dendrite::Generators::Base::new
# File lib/dendrite/generators/nerve.rb, line 7
def initialize(graph:, service_names:)
  super
  @services = @services.collect { |service| ServiceConfig.new(service)}
end

Public Instance Methods

to_h() click to toggle source
# File lib/dendrite/generators/nerve.rb, line 12
def to_h
  service_list = services.inject({}) do |hash, service|
    if service.read_write
      hash[service.name] = service.to_h
      hash["#{service.name}_readonly"] = service.to_h.merge({
        zk_path: "/smartstack/services/#{service.organization}/#{service.component}/#{service.service.real_name}_readonly/instances"
      })
    elsif service.read_only
      hash["#{service.name}_readonly"] = service.to_h.merge({
        zk_path: "/smartstack/services/#{service.organization}/#{service.component}/#{service.service.real_name}_readonly/instances"
      })
    else
      hash[service.name] = service.to_h
    end

    hash
  end

  {
    instance_id: Dendrite::Config.instance
  }.merge({services: service_list})
end