Class: DTK::State::Component::Attribute::Influxdb::Client
- Inherits:
-
Object
- Object
- DTK::State::Component::Attribute::Influxdb::Client
- Defined in:
- lib/state/component/providers/influxdb/client.rb
Constant Summary collapse
- INFLUXDB_SECRET_DIR =
'/app/influxdb/'
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#connection_parameters ⇒ Object
readonly
Returns the value of attribute connection_parameters.
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #measurement_helper(measurement_name) ⇒ Object
- #query(query_expression) ⇒ Object
- #write_point(data) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/state/component/providers/influxdb/client.rb', line 7 def initialize @connection_parameters = return_connection_parameters @connection = return_connection(@connection_parameters) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
39 40 41 |
# File 'lib/state/component/providers/influxdb/client.rb', line 39 def connection @connection end |
#connection_parameters ⇒ Object (readonly)
Returns the value of attribute connection_parameters.
39 40 41 |
# File 'lib/state/component/providers/influxdb/client.rb', line 39 def connection_parameters @connection_parameters end |
Instance Method Details
#measurement_helper(measurement_name) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/state/component/providers/influxdb/client.rb', line 30 def measurement_helper(measurement_name) begin klass = Measurement.const_get(measurement_name.to_sym.capitalize) klass.new(measurement_name, self) rescue => error fail error end end |
#query(query_expression) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/state/component/providers/influxdb/client.rb', line 12 def query(query_expression) begin query_api = self.connection.create_query_api query_api.query(query_expression) rescue => error fail "Failed in query" end end |
#write_point(data) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/state/component/providers/influxdb/client.rb', line 21 def write_point(data) begin write_api = self.connection.create_write_api write_api.write(data: data) rescue => error fail error end end |