Class: OnesnooperServer::SqlStore

Inherits:
Store
  • Object
show all
Defined in:
lib/onesnooper_server/sql_store.rb

Overview

Class wrapping common features of all SQL-based stores. Using 'sequel' to abstract differences.

Constant Summary collapse

SQL_TABLE_NAME =

constant table name

:one_monitoring

Instance Method Summary collapse

Methods inherited from Store

#initialize

Constructor Details

This class inherits a constructor from OnesnooperServer::Store

Instance Method Details

#save!(timestamp, data) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/onesnooper_server/sql_store.rb', line 10

def save!(timestamp, data)
  ::OnesnooperServer::Log.debug "[#{self.class.name}] Saving #{timestamp.to_s} => #{data.inspect}"
  fail "DB connection has to be initialized from subclasses, " \
       "::OnesnooperServer::SqlStore cannot be used directly!" unless @db_conn

  if insert_data = data_in_vm_groups(timestamp, data)
    @db_conn[SQL_TABLE_NAME].multi_insert(insert_data)
  else
    ::OnesnooperServer::Log.warn "[#{self.class.name}] Skipping SQL INSERT for an empty dataset"
  end
end