class Turn::Term
Public Class Methods
new(hostname, port)
click to toggle source
# File lib/turn/term.rb, line 7 def initialize(hostname, port) @hostname = hostname @port = port end
Public Instance Methods
dump_bucket_map(dc)
click to toggle source
# File lib/turn/term.rb, line 12 def dump_bucket_map(dc) hash = get('dump profile bucket map', dc: dc) fail hash['errors'] unless hash['errors'].empty? hash['info'] end
dump_public_metrics(prefix)
click to toggle source
# File lib/turn/term.rb, line 20 def dump_public_metrics(prefix) metrics = {} hash = get('dump public metrics', prefix: prefix) hash['rows'].each do |metric| metrics[metric.first] = metric.last.to_i end metrics end
get(command, query)
click to toggle source
# File lib/turn/term.rb, line 31 def get(command, query) q = { command: command, 'response-formatter' => 'json' } uri = URI("http://#{@hostname}:#{@port}/execute") uri.query = URI.encode_www_form(q.merge(query)) json = RestClient.get(uri.to_s) hash = JSON.parse(json) fail unless hash['errors'].empty? && hash['warnings'].empty? hash end