Method: Aggkit::Consul#build_consul_addr
- Defined in:
- lib/aggkit/consul.rb
#build_consul_addr(addr: , host: , port: ) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aggkit/consul.rb', line 18 def build_consul_addr(addr: ENV['CONSUL_HTTP_ADDR'], host: ENV['CONSUL_HOST'], port: ENV['CONSUL_PORT']) return URI('http://localhost:8500') if addr.to_s.empty? && host.to_s.empty? && port.to_s.empty? return URI(addr) unless addr.to_s.empty? uri = URI(host) uri = URI("http://#{host}:8500") if uri.scheme.to_s.empty? if port.to_s.empty? uri.port = 8500 if uri.port.to_i == 80 else uri.port = port.to_i end uri end |