Class: InfluxORM::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/influx_orm/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, configuration) ⇒ Connection

Returns a new instance of Connection.



5
6
7
8
# File 'lib/influx_orm/connection.rb', line 5

def initialize(options, configuration)
  @config = options.with_indifferent_access
  @configuration = configuration
end

Instance Attribute Details

#client_configObject (readonly)

Returns the value of attribute client_config.



3
4
5
# File 'lib/influx_orm/connection.rb', line 3

def client_config
  @client_config
end

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/influx_orm/connection.rb', line 3

def config
  @config
end

#configurationObject (readonly)

Returns the value of attribute configuration.



3
4
5
# File 'lib/influx_orm/connection.rb', line 3

def configuration
  @configuration
end

#databaseObject (readonly)

Returns the value of attribute database.



3
4
5
# File 'lib/influx_orm/connection.rb', line 3

def database
  @database
end

Instance Method Details

#dbObject



10
11
12
# File 'lib/influx_orm/connection.rb', line 10

def db
  @db ||= InfluxDB::Client.new(config)
end

#import(data) ⇒ Object



22
23
24
# File 'lib/influx_orm/connection.rb', line 22

def import(data)
  log("IMPORT #{data}") { db.write_points(data) }
end

#insert(table_name, point) ⇒ Object



18
19
20
# File 'lib/influx_orm/connection.rb', line 18

def insert(table_name, point)
  log("INSERT to #{table_name}: #{point}") { db.write_point(table_name, point) }
end

#query(sql) ⇒ Object



14
15
16
# File 'lib/influx_orm/connection.rb', line 14

def query(sql)
  log(sql) { db.query(sql) }
end