Module: Etcd::Requestable

Includes:
Loggable
Included in:
Client, Cluster, Node
Defined in:
lib/etcd/requestable.rb

Instance Method Summary collapse

Methods included from Loggable

#logger, #reset_logger!

Instance Method Details

#http_clientObject


4
5
6
# File 'lib/etcd/requestable.rb', line 4

def http_client
  @http_client ||= reset_http_client!
end

#request(method, uri, args = {}) ⇒ Object


12
13
14
15
# File 'lib/etcd/requestable.rb', line 12

def request(method, uri, args={})
  logger.debug("request - #{method} #{uri} #{args.inspect}")
  http_client.request(method, uri, args.merge(follow_redirect: true))
end

#request_data(method, uri, args = {}) ⇒ Object


17
18
19
20
21
22
# File 'lib/etcd/requestable.rb', line 17

def request_data(method, uri, args={})
  response = request(method, uri, args)
  if response.status_code == 200
    MultiJson.load(response.body)
  end
end

#reset_http_client!Object


8
9
10
# File 'lib/etcd/requestable.rb', line 8

def reset_http_client!
  @http_client = HTTPClient.new(agent_name: "etcd-rb/#{VERSION}")
end