Class: Threatinator::Amqp::Rcvr::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/threatinator/amqp/rcvr/table.rb

Direct Known Subclasses

FQDNTable, IPTable

Instance Method Summary collapse

Constructor Details

#initialize(backends = 'sqlite3') ⇒ Table

Returns a new instance of Table.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/threatinator/amqp/rcvr/table.rb', line 7

def initialize(backends='sqlite3')
  puts "#[threatinator-ampq-rcvr] backend - #{backends}" if Threatinator::Amqp::Rcvr::Settings.verbose
  @db =  Threatinator::Amqp::Rcvr::Backends::SQLite.new
  @db.validate!
  @db.prep

  @conn = Bunny.new(:hostname => Threatinator::Amqp::Rcvr::Settings.amqp_hostname, :automatically_recover => false)
  @conn.start
  @ch  = @conn.create_channel
  @x   = @ch.topic(Threatinator::Amqp::Rcvr::Settings.amqp_binding_topic)
  @q   = @ch.queue("", :exclusive => true)
  @q.bind(@x, :routing_key => Threatinator::Amqp::Rcvr::Settings.amqp_routing_key)
end

Instance Method Details

#closeObject



21
22
23
24
25
26
27
# File 'lib/threatinator/amqp/rcvr/table.rb', line 21

def close
  @ch.close
  @conn.close
  @db.close
  puts "#[threatinator-ampq-rcvr] All connections closed" if Threatinator::Amqp::Rcvr::Settings.verbose
  exit 0
end