Class: Sqlx::Database::LeaseToken

Inherits:
Object
  • Object
show all
Defined in:
runtime/database/lease.rb

Overview

One checked-out pool position. The pool owns the connection array; the token carries only the position, so the shared lease code never names a concrete connection type (spinel types the adapter's own array concretely).

Instance Method Summary collapse

Constructor Details

#initialize(pool, index) ⇒ LeaseToken

Returns a new instance of LeaseToken.



25
26
27
28
# File 'runtime/database/lease.rb', line 25

def initialize(pool, index)
  @pool = pool
  @index = index
end

Instance Method Details

#connection ⇒ Object



30
31
32
# File 'runtime/database/lease.rb', line 30

def connection
  @pool.conn(@index)
end

#release(conn, finished) ⇒ Object



34
35
36
# File 'runtime/database/lease.rb', line 34

def release(conn, finished)
  @pool.release(@index, conn, finished)
end