Sha256: 451d31aa8ee1cc490b390a3965a239180671401de88ee6376e17400fb25393b6

Contents?: true

Size: 682 Bytes

Versions: 15

Compression:

Stored size: 682 Bytes

Contents

module RabbitFeed
  class Connection
    include Singleton

    def initialize
      RabbitFeed.log.info {{ event: :connecting_to_rabbitmq, options: RabbitFeed.configuration.connection_options.merge({password: :redacted, logger: :redacted}) }}
      @connection = Bunny.new RabbitFeed.configuration.connection_options
      @connection.start
      RabbitFeed.log.info {{ event: :connected_to_rabbitmq }}
      @channel = @connection.create_channel
      @mutex = Mutex.new
    end

    private

    attr_reader :channel, :mutex

    def synchronized &block
      mutex.synchronize do
        yield
      end
    end

    def connection_in_use?
      mutex.locked?
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rabbit_feed-2.4.4 lib/rabbit_feed/connection.rb
rabbit_feed-2.4.3 lib/rabbit_feed/connection.rb
rabbit_feed-2.4.2 lib/rabbit_feed/connection.rb
rabbit_feed-2.4.1 lib/rabbit_feed/connection.rb
rabbit_feed-2.4.0 lib/rabbit_feed/connection.rb
rabbit_feed-2.3.10 lib/rabbit_feed/connection.rb
rabbit_feed-2.3.9 lib/rabbit_feed/connection.rb
rabbit_feed-2.3.7 lib/rabbit_feed/connection.rb
rabbit_feed-2.3.6 lib/rabbit_feed/connection.rb
rabbit_feed-2.3.5 lib/rabbit_feed/connection.rb
rabbit_feed-2.3.4 lib/rabbit_feed/connection.rb
rabbit_feed-2.3.3 lib/rabbit_feed/connection.rb
rabbit_feed-2.3.2 lib/rabbit_feed/connection.rb
rabbit_feed-2.3.1 lib/rabbit_feed/connection.rb
rabbit_feed-2.3.0 lib/rabbit_feed/connection.rb