Class: Thm::DataServices
- Inherits:
-
Object
- Object
- Thm::DataServices
- Defined in:
- lib/thm/dataservices.rb
Direct Known Subclasses
Defined Under Namespace
Classes: External, Geocoding, Geolocation, Safebrowsing, Trafviz
Instance Attribute Summary collapse
-
#autocommit ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#datastore ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#dbhost ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#dbname ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#dbpass ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#dbuser ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#debug ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#mqhost ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#mqpass ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#mquser ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#mqvhost ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#queueprefix ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#tblname_ippacket ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#tblname_tcppacket ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
-
#tblname_udppacket ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight.
Instance Method Summary collapse
- #commit ⇒ Object
- #dbconnect ⇒ Object
-
#initialize ⇒ DataServices
constructor
A new instance of DataServices.
- #mqclose ⇒ Object
- #mqconnect ⇒ Object
- #query(sql) ⇒ Object
Constructor Details
#initialize ⇒ DataServices
Returns a new instance of DataServices.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/thm/dataservices.rb', line 18 def initialize @autocommit = false @datastore = "monetdb" @debug = false @mqhost = "127.0.0.1" @mquser = "traffic" @mqpass = "dk3rbi9l" @mqvhost = "/" @dbhost = "127.0.0.1" @dbuser = "threatmonitor" @dbpass = "dk3rbi9l" @dbname = "threatmonitor" @queueprefix = "cactus" # Queue names will be come prefixed with cactus_ippacket etc .. # Implement tblname for table freedom @tblname_ippacket = "ippacket" @tblname_tcppacket = "tcppacket" @tblname_udppacket = "udppacket" @mqconn = Bunny.new(:hostname => "#{@mqhost}", :user => "#{@mquser}", :pass => "#{@mqpass}", :vhost => "#{@mqvhost}") end |
Instance Attribute Details
#autocommit ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def autocommit @autocommit end |
#datastore ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def datastore @datastore end |
#dbhost ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def dbhost @dbhost end |
#dbname ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def dbname @dbname end |
#dbpass ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def dbpass @dbpass end |
#dbuser ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def dbuser @dbuser end |
#debug ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def debug @debug end |
#mqhost ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def mqhost @mqhost end |
#mqpass ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def mqpass @mqpass end |
#mquser ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def mquser @mquser end |
#mqvhost ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def mqvhost @mqvhost end |
#queueprefix ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def queueprefix @queueprefix end |
#tblname_ippacket ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def tblname_ippacket @tblname_ippacket end |
#tblname_tcppacket ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def tblname_tcppacket @tblname_tcppacket end |
#tblname_udppacket ⇒ Object
This class provides all the core functionality to the lower level DatalayerLight
Example variables
obj = Thm::Producer.new
obj.mqhost = "127.0.0.1"
obj.mquser = "test"
obj.mqpass = "setone"
obj.mqconnect
obj.dbconnect
16 17 18 |
# File 'lib/thm/dataservices.rb', line 16 def tblname_udppacket @tblname_udppacket end |
Instance Method Details
#commit ⇒ Object
74 75 76 |
# File 'lib/thm/dataservices.rb', line 74 def commit @conn.commit end |
#dbconnect ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/thm/dataservices.rb', line 47 def dbconnect if @datastore == "mysql" @conn = DatalayerLight::MySQLDrv.new puts "Using MySQL Datasource" elsif @datastore == "monetdb" @conn = DatalayerLight::MonetDBDrv.new puts "Using MonetDB Datasource" end @conn.hostname = @dbhost @conn.username = @dbuser @conn.password = @dbpass @conn.dbname = @dbname @conn.debug = @debug @conn.autocommit = @autocommit begin @conn.connect rescue Errno::ECONNREFUSED puts "Database not running!" puts "Bye!" exit end end |
#mqclose ⇒ Object
43 44 45 |
# File 'lib/thm/dataservices.rb', line 43 def mqclose @conn.close end |
#mqconnect ⇒ Object
38 39 40 41 |
# File 'lib/thm/dataservices.rb', line 38 def mqconnect @mqconn.start @ch = @mqconn.create_channel end |
#query(sql) ⇒ Object
70 71 72 |
# File 'lib/thm/dataservices.rb', line 70 def query(sql) res = @conn.query("#{sql}") end |