Module: Sequel::TemporarilyReleaseConnection::PoolMethods

Defined in:
lib/sequel/extensions/temporarily_release_connection.rb

Instance Method Summary collapse

Instance Method Details

#temporarily_release_connection(conn, server) ⇒ Object

Temporarily release a currently checked out connection, then yield to the block. Reacquire the same connection upon the exit of the block.

Raises:



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/sequel/extensions/temporarily_release_connection.rb', line 75

def temporarily_release_connection(conn, server)
  t = Sequel.current
  raise Error, "connection not currently checked out" unless conn.equal?(trc_owned_connection(t, server))

  begin
    trc_release(t, conn, server)
    yield
  ensure
    c = trc_acquire(t, server)
    unless conn.equal?(c)
      raise UnableToReacquireConnectionError, "reacquired connection not the same as initial connection"
    end
  end
end