Class: Dendrite::Generators::Nerve::ServiceConfig

Inherits:
Struct
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/dendrite/generators/nerve.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#serviceObject

Returns the value of attribute service

Returns:

  • (Object)

    the current value of service



35
36
37
# File 'lib/dendrite/generators/nerve.rb', line 35

def service
  @service
end

Instance Method Details

#check_configObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/dendrite/generators/nerve.rb', line 60

def check_config
  return {} if not (service.service_port && service.telemetry && service.telemetry.health_url)
  {
    check_interval: Dendrite::Config.default_check_time,
    checks: [{
      type: "http",
      host: Dendrite::Config.public_ip,
      port: service.service_port,
      uri: service.telemetry.health_url,
      rise: 3,
      fall: 2
    }]
  }
end

#read_onlyObject



41
42
43
# File 'lib/dendrite/generators/nerve.rb', line 41

def read_only
  service. && service..read_only
end

#read_writeObject



45
46
47
# File 'lib/dendrite/generators/nerve.rb', line 45

def read_write
  read_only && service..write_only
end

#to_hObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/dendrite/generators/nerve.rb', line 49

def to_h
  {
    host: Dendrite::Config.public_ip,
    port: service.service_port || DEFAULT_PORT,
    labels: {
      dc: Dendrite::Config.dc,
      env: Dendrite::Config.env
    }
  }.merge(zookeeper_config).merge(check_config)
end

#zookeeper_configObject



75
76
77
78
79
80
81
# File 'lib/dendrite/generators/nerve.rb', line 75

def zookeeper_config
  {
    reporter_type: 'zookeeper',
    zk_hosts: Dendrite::Config.zk_hosts,
    zk_path: "/smartstack/services/#{organization}/#{component}/#{service.real_name}/instances"
  }
end