Class: Opentsdb::Faraday

Inherits:
Object
  • Object
show all
Defined in:
lib/opentsdb/faraday.rb

Overview

:nodoc:

Constant Summary collapse

DEFAULT_TIMEOUT =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Faraday

Returns a new instance of Faraday.



8
9
10
11
# File 'lib/opentsdb/faraday.rb', line 8

def initialize(url, options = {})
  @url = url
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/opentsdb/faraday.rb', line 5

def options
  @options
end

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/opentsdb/faraday.rb', line 5

def url
  @url
end

Instance Method Details

#post(body) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/opentsdb/faraday.rb', line 13

def post(body)
  connection.post do |req|
    req.headers         = headers
    req.body            = body
    req.options.timeout = options[:timeout] || DEFAULT_TIMEOUT
    req.options.open_timeout = options[:open_timeout] || DEFAULT_TIMEOUT
  end
end