Sha256: 848a7f648b5956905c9b280359841ebd2f469628bf487b92837b7038386a1404
Contents?: true
Size: 1.12 KB
Versions: 6
Compression:
Stored size: 1.12 KB
Contents
class Skein::Connected # == Properties =========================================================== attr_reader :context attr_reader :ident attr_reader :connection attr_reader :channel # == Instance Methods ===================================================== def initialize(connection: nil, context: nil) @mutex = Mutex.new @shared_connection = !!connection @connection = connection || Skein::RabbitMQ.connect @channel = @connection.create_channel @context = context || Skein::Context.new @ident = @context.ident(self) end def lock @mutex.synchronize do yield end end def close lock do begin @channel and @channel.close rescue => e if (defined?(MarchHare)) case e when MarchHare::ChannelLevelException, MarchHare::ChannelAlreadyClosed # Ignored since we're finished with the channel anyway else raise e end end end @channel = nil unless (@shared_connection) @connection and @connection.close @connection = nil end end end end
Version data entries
6 entries across 6 versions & 1 rubygems