class Threatinator::Plugins::Output::Amqp
Public Class Methods
new(config)
click to toggle source
# File lib/threatinator/plugins/output/amqp.rb, line 16 def initialize(config) bunny_config = { recover_from_connection_close: true, network_recovery_interval: 5.0 } @bunny = Bunny.new(config.url, bunny_config) @bunny.start @channel = @bunny.create_channel @exchange = @channel.topic("threats") end
Public Instance Methods
finish()
click to toggle source
# File lib/threatinator/plugins/output/amqp.rb, line 35 def finish @exchange = nil @bunny.close end
handle_event(event)
click to toggle source
# File lib/threatinator/plugins/output/amqp.rb, line 27 def handle_event(event) # Routing keys are dynamic event_types #@routing_key = config.routing_key || 'threatinator.' + event.type.to_s @routing_key = 'threatinator.' + event.type.to_s @exchange.publish(MultiJson.dump(event.to_serializable_hash), routing_key: @routing_key) end