Sha256: 034c1992595e18ccfd6f5faaea5e4e487def519287d7cf7c8fbda2467cc37043

Contents?: true

Size: 619 Bytes

Versions: 6

Compression:

Stored size: 619 Bytes

Contents

require 'singleton'

module RabbitCarrots
  class Connection
    include ::Singleton
    attr_reader :connection

    def initialize
      @connection = Bunny.new(
        host: RabbitCarrots.configuration.rabbitmq_host,
        port: RabbitCarrots.configuration.rabbitmq_port,
        user: RabbitCarrots.configuration.rabbitmq_user,
        password: RabbitCarrots.configuration.rabbitmq_password,
        vhost: RabbitCarrots.configuration.rabbitmq_vhost
      )

      @connection.start
    end

    def channel
      @channel ||= ConnectionPool.new do
        connection.create_channel
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rabbit_carrots-0.1.20 lib/rabbit_carrots/connection.rb
rabbit_carrots-0.1.19 lib/rabbit_carrots/connection.rb
rabbit_carrots-0.1.18 lib/rabbit_carrots/connection.rb
rabbit_carrots-0.1.17 lib/rabbit_carrots/connection.rb
rabbit_carrots-0.1.16 lib/rabbit_carrots/connection.rb
rabbit_carrots-0.1.15 lib/rabbit_carrots/connection.rb