Class: Dendrite::Config

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

Class Method Summary collapse

Class Method Details

.bind_to_all?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/dendrite.rb', line 87

def bind_to_all?
  @@data[:dendrite][:bind_to_all] != nil
end


79
80
81
# File 'lib/dendrite.rb', line 79

def cookie
  @@data[:dendrite][:cookie] || "COOKME"
end

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



61
62
63
64
65
66
67
68
69
# File 'lib/dendrite.rb', line 61

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



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

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

.default_check_timeObject



91
92
93
# File 'lib/dendrite.rb', line 91

def default_check_time
  @@data[:dendrite][:check_internal] || 5
end

.envObject



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

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

.fqdnObject



101
102
103
# File 'lib/dendrite.rb', line 101

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

.global_haproxy_configObject



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

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

.http_typesObject



75
76
77
# File 'lib/dendrite.rb', line 75

def http_types
  @@data[:dendrite][:http_app_types] || []
end

.instanceObject



105
106
107
# File 'lib/dendrite.rb', line 105

def instance
  fqdn
end

.load(source:) ⇒ Object



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

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

.nerve_config_pathObject



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

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

.peerObject



54
55
56
57
58
59
# File 'lib/dendrite.rb', line 54

def peer
  if @@data[:synapse][:haproxy][:extra_sections]
    key = @@data[:synapse][:haproxy][:extra_sections].keys.collect(&:to_s).find {|k| k.include?("peers")}
    key ? key.split("peers").last.strip : nil
  end
end

.public_ipObject



95
96
97
98
99
# File 'lib/dendrite.rb', line 95

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

.server_optionsObject



50
51
52
# File 'lib/dendrite.rb', line 50

def server_options
  @@data[:synapse][:server_options]
end

.services_sourceObject



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

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

.stickyObject



83
84
85
# File 'lib/dendrite.rb', line 83

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

.synapse_config_pathObject



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

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

.valid_typesObject



71
72
73
# File 'lib/dendrite.rb', line 71

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

.zk_hostsObject



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

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