module ConsulDo

Constants

VERSION

Public Class Methods

config() click to toggle source
# File lib/consul_do.rb, line 8
def self.config
  @config ||= Config.new
end
configure!() { |config| ... } click to toggle source
# File lib/consul_do.rb, line 12
def self.configure!
  @config = Config.new
  yield config
end
elect() click to toggle source
# File lib/consul_do.rb, line 17
def self.elect
  @elect ||= Elect.new
end
elect!() click to toggle source
# File lib/consul_do.rb, line 21
def self.elect!
  @elect = Elect.new
end
http_get(dest_url) click to toggle source
# File lib/consul_do.rb, line 31
def self.http_get(dest_url)
  log "http_get", config.http_client.get_response(URI(dest_url))
end
http_put(dest_url, data = nil) click to toggle source
# File lib/consul_do.rb, line 25
def self.http_put(dest_url, data = nil)
  uri = URI.parse(dest_url)
  request = config.http_client.new(uri.host, uri.port)
  log "http_put", request.send_request('PUT', "#{ [uri.path, uri.query].compact.join('?') }", data.to_json, {'Content-type' => 'application/json'})
end
log(msg, retval) click to toggle source
# File lib/consul_do.rb, line 35
def self.log(msg, retval)
  puts [msg,retval.to_s].join(":\n  ") if config.verbose
  retval
end