Class: Dendrite::Config
- Inherits:
-
Object
- Object
- Dendrite::Config
- Defined in:
- lib/dendrite.rb
Class Method Summary collapse
- .bind_to_all? ⇒ Boolean
- .cookie ⇒ Object
- .custom_frontend!(name:, port:, backend_name:) ⇒ Object
- .dc ⇒ Object
- .default_check_time ⇒ Object
- .env ⇒ Object
- .fqdn ⇒ Object
- .global_haproxy_config ⇒ Object
- .http_types ⇒ Object
- .instance ⇒ Object
- .load(source:) ⇒ Object
- .nerve_config_path ⇒ Object
- .peer ⇒ Object
- .public_ip ⇒ Object
- .server_options ⇒ Object
- .services_source ⇒ Object
- .sticky ⇒ Object
- .synapse_config_path ⇒ Object
- .valid_types ⇒ Object
- .zk_hosts ⇒ Object
Class Method Details
.bind_to_all? ⇒ Boolean
87 88 89 |
# File 'lib/dendrite.rb', line 87 def bind_to_all? @@data[:dendrite][:bind_to_all] != nil end |
.cookie ⇒ Object
79 80 81 |
# File 'lib/dendrite.rb', line 79 def @@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 |
.dc ⇒ Object
26 27 28 |
# File 'lib/dendrite.rb', line 26 def dc @@data[:dendrite].fetch(:dc) end |
.default_check_time ⇒ Object
91 92 93 |
# File 'lib/dendrite.rb', line 91 def default_check_time @@data[:dendrite][:check_internal] || 5 end |
.env ⇒ Object
30 31 32 |
# File 'lib/dendrite.rb', line 30 def env @@data[:dendrite][:env] || :dev end |
.fqdn ⇒ Object
101 102 103 |
# File 'lib/dendrite.rb', line 101 def fqdn Socket.gethostbyname(Socket.gethostname).first end |
.global_haproxy_config ⇒ Object
46 47 48 |
# File 'lib/dendrite.rb', line 46 def global_haproxy_config @@data[:synapse][:haproxy] end |
.http_types ⇒ Object
75 76 77 |
# File 'lib/dendrite.rb', line 75 def http_types @@data[:dendrite][:http_app_types] || [] end |
.instance ⇒ Object
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_path ⇒ Object
38 39 40 |
# File 'lib/dendrite.rb', line 38 def nerve_config_path @@data[:dendrite][:nerve_config_path] end |
.peer ⇒ Object
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_ip ⇒ Object
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_options ⇒ Object
50 51 52 |
# File 'lib/dendrite.rb', line 50 def @@data[:synapse][:server_options] end |
.services_source ⇒ Object
22 23 24 |
# File 'lib/dendrite.rb', line 22 def services_source @@data[:dendrite].fetch(:services_source) end |
.sticky ⇒ Object
83 84 85 |
# File 'lib/dendrite.rb', line 83 def sticky @@data[:dendrite][:sticky] end |
.synapse_config_path ⇒ Object
42 43 44 |
# File 'lib/dendrite.rb', line 42 def synapse_config_path @@data[:dendrite][:synapse_config_path] end |
.valid_types ⇒ Object
71 72 73 |
# File 'lib/dendrite.rb', line 71 def valid_types @@data[:dendrite][:valid_app_types] end |
.zk_hosts ⇒ Object
34 35 36 |
# File 'lib/dendrite.rb', line 34 def zk_hosts @@data[:dendrite][:zk_hosts] end |