Class: Squirm::Rails::ConnectionPool

Inherits:
Object
  • Object
show all
Defined in:
lib/squirm/rails/connection_pool.rb

Instance Method Summary collapse

Constructor Details

#initializeConnectionPool

Returns a new instance of ConnectionPool.



5
6
7
8
# File 'lib/squirm/rails/connection_pool.rb', line 5

def initialize
  @pool = ActiveRecord::Base.connection_pool
  @map  = {}
end

Instance Method Details

#checkin(raw_connection) ⇒ Object



17
18
19
# File 'lib/squirm/rails/connection_pool.rb', line 17

def checkin(raw_connection)
  @pool.checkin @map[raw_connection.object_id]
end

#checkoutObject



10
11
12
13
14
15
# File 'lib/squirm/rails/connection_pool.rb', line 10

def checkout
  conn = @pool.checkout
  raw_connection = conn.raw_connection
  @map[raw_connection.object_id] = conn
  raw_connection
end