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.
33 34 35 |
# File 'lib/state/component/providers/influxdb/client.rb', line 33 def connection @connection end |
#connection_parameters ⇒ Object (readonly)
Returns the value of attribute connection_parameters.
33 34 35 |
# File 'lib/state/component/providers/influxdb/client.rb', line 33 def connection_parameters @connection_parameters end |
Instance Method Details
#measurement_helper(measurement_name) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/state/component/providers/influxdb/client.rb', line 26 def measurement_helper(measurement_name) klass = Measurement.const_get(measurement_name.to_sym.capitalize) klass.new(measurement_name, self) rescue => e raise e end |
#query(query_expression) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/state/component/providers/influxdb/client.rb', line 12 def query(query_expression) query_api = self.connection.create_query_api query_api.query(query_expression) rescue => e raise "Failed while processing flux query!. Error: #{e}" end |
#write_point(data) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/state/component/providers/influxdb/client.rb', line 19 def write_point(data) write_api = self.connection.create_write_api write_api.write(data: data) rescue => e raise e end |