Sha256: 7a3a4f45d0e6f30f71b57d2a16efd7775978887e7c9967e617c1251a34273322
Contents?: true
Size: 948 Bytes
Versions: 5
Compression:
Stored size: 948 Bytes
Contents
module PikaQue class Connection extend Forwardable def_delegators :@connection, :create_channel include Logging attr_reader :connection def initialize(opts = {}) @opts = PikaQue.config.merge(opts) end def self.create(opts = {}) new(opts).tap{ |conn| conn.connect! } end def connect! @connection ||= Bunny.new(@opts[:amqp], :vhost => @opts[:vhost], :heartbeat => @opts[:heartbeat], :properties => @opts.fetch(:properties, {}), :logger => PikaQue::logger).tap do |conn| conn.start end end def connected? @connection && @connection.connected? end def disconnect! @connection.close if @connection @connection = nil end def ensure_connection unless connected? @connection = nil connect! end end end end
Version data entries
5 entries across 5 versions & 1 rubygems