Sha256: c60701cd268bb2f5fd466bb3d4f09b0ed08bc1f20b717fbd43eddb4fd82456c6
Contents?: true
Size: 849 Bytes
Versions: 2
Compression:
Stored size: 849 Bytes
Contents
require 'diplomat' module Skalera module Services class Consul def self.configure(service_name) consul = ENV['CONSUL'] || 'consul' Diplomat.configuration.url = "http://#{consul}:8500" token = ENV['CONSUL_ACL_TOKEN'] Diplomat.configuration.acl_token = token if token # force a lookup just to make a connection so we can bail out early if consul is down Diplomat.get("services/#{service_name}") rescue Diplomat::KeyNotFound Diplomat.put("services/#{service_name}", service_name) rescue Faraday::ConnectionFailed => e # TODO: use logging STDERR.puts("ERROR: could not lookup host #{consul}") raise e rescue Faraday::ClientError => e # TODO: use logging STDERR.puts("ERROR: #{e}") raise e end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
skalera-services-0.2.5 | lib/skalera/services/consul.rb |
skalera-services-0.2.4 | lib/skalera/services/consul.rb |