Class: Dendrite::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/dendrite.rb

Class Method Summary collapse

Class Method Details

.custom_frontend!(name:, port:, backend_name:) ⇒ Object



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

def custom_frontend!(name:, port:, backend_name:)
  data = {
    "frontend #{name}": [
      "bind :#{port}",
      "use_backend #{backend_name}"
    ]
  }
  @@data[:synapse][:haproxy][:extra_sections] = @@data[:synapse][:haproxy][:extra_sections].merge(data)
end

.dcObject



25
26
27
# File 'lib/dendrite.rb', line 25

def dc
  @@data[:dendrite].fetch(:dc)
end

.envObject



29
30
31
# File 'lib/dendrite.rb', line 29

def env
  @@data[:dendrite][:env] || :dev
end

.fqdnObject



69
70
71
# File 'lib/dendrite.rb', line 69

def fqdn
  Socket.gethostbyname(Socket.gethostname).first
end

.global_haproxy_configObject



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

def global_haproxy_config
  @@data[:synapse][:haproxy]
end

.instanceObject



73
74
75
# File 'lib/dendrite.rb', line 73

def instance
  fqdn
end

.load(source:) ⇒ Object



17
18
19
# File 'lib/dendrite.rb', line 17

def load(source:)
  @@data = Dendrite::IO.read(source: source)
end

.nerve_config_pathObject



37
38
39
# File 'lib/dendrite.rb', line 37

def nerve_config_path
  @@data[:dendrite][:nerve_config_path]
end

.public_ipObject



63
64
65
66
67
# File 'lib/dendrite.rb', line 63

def public_ip
  ip = Socket.ip_address_list.detect{|intf| intf.ipv4_private?} ||
       Socket.ip_address_list.detect{|intf| intf.ipv4? && !intf.ipv4_loopback? && !intf.ipv4_multicast? && !intf.ipv4_private?}
  ip.ip_address if ip
end

.services_sourceObject



21
22
23
# File 'lib/dendrite.rb', line 21

def services_source
  @@data[:dendrite].fetch(:services_source)
end

.synapse_config_pathObject



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

def synapse_config_path
  @@data[:dendrite][:synapse_config_path]
end

.valid_typesObject



59
60
61
# File 'lib/dendrite.rb', line 59

def valid_types
  @@data[:dendrite][:valid_app_types]
end

.zk_hostsObject



33
34
35
# File 'lib/dendrite.rb', line 33

def zk_hosts
  @@data[:dendrite][:zk_hosts]
end