Class: Opentsdb::Client
- Inherits:
-
Object
- Object
- Opentsdb::Client
- Extended by:
- Forwardable
- Defined in:
- lib/opentsdb/client.rb
Overview
ruby client for OpenTsdb HTTP API
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#query_options ⇒ Object
readonly
Returns the value of attribute query_options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #parse_queries ⇒ Object
- #query ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 |
# File 'lib/opentsdb/client.rb', line 11 def initialize( = {}) @host = .delete(:host) || Opentsdb.host @port = .delete(:port) || Opentsdb.port @http = HttpClient.new = end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/opentsdb/client.rb', line 9 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
9 10 11 |
# File 'lib/opentsdb/client.rb', line 9 def port @port end |
#query_options ⇒ Object (readonly)
Returns the value of attribute query_options.
9 10 11 |
# File 'lib/opentsdb/client.rb', line 9 def end |
Instance Method Details
#parse_queries ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/opentsdb/client.rb', line 26 def parse_queries [].tap do |qs| [:q].split(';').each do |q| query = QueryParser.parse(q) query.interval = [:interval] query.start_time = [:begin].to_i query.end_time = [:end].to_i qs << query end end end |
#query ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/opentsdb/client.rb', line 18 def query [].tap do |data| parse_queries.each do |query_commad| data << post(query_uri, query_commad.to_json) end end end |