Sha256: 7ca9d161ce1c4c0f23ab72ae6e0c24430e866e91418240789257e470e75249a3
Contents?: true
Size: 849 Bytes
Versions: 4
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 id 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
4 entries across 4 versions & 1 rubygems