Sha256: 37edc5448f5f097311733b7dbc286a946d034cb927a28a0997c0411dcaf412de

Contents?: true

Size: 470 Bytes

Versions: 2

Compression:

Stored size: 470 Bytes

Contents

require 'json'
require 'bunny'

class Sender
  def initialize config
    @connection = Bunny.new("amqp://#{config[:bunny_username]}:#{config[:bunny_password]}@#{config[:bunny_host]}").start
    @channel = @connection.create_channel
    @exchange = @channel.fanout('lighting.messages')
  end

  def message_send status, type
    message = Hash status: status, type: type
    @exchange.publish message.to_json
  end

  def close_connection
    @connection.close
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
test_driven_lighting-1.2.0 lib/test_driven_lighting/sender.rb
test_driven_lighting-1.1.0 lib/test_driven_lighting/sender.rb