Class: Que::Adapters::ActiveRecord

Inherits:
Base
  • Object
show all
Defined in:
lib/que/adapters/active_record.rb

Instance Method Summary collapse

Methods inherited from Base

#execute, #in_transaction?, #initialize, #wake_worker_after_commit

Constructor Details

This class inherits a constructor from Que::Adapters::Base

Instance Method Details

#checkoutObject



6
7
8
# File 'lib/que/adapters/active_record.rb', line 6

def checkout
  checkout_activerecord_adapter { |conn| yield conn.raw_connection }
end

#cleanup!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/que/adapters/active_record.rb', line 10

def cleanup!
  # ActiveRecord will check out connections to the current thread when
  # queries are executed and not return them to the pool until
  # explicitly requested to. The wisdom of this API is questionable, and
  # it doesn't pose a problem for the typical case of workers using a
  # single PG connection (since we ensure that connection is checked in
  # and checked out responsibly), but since ActiveRecord supports
  # connections to multiple databases, it's easy for people using that
  # feature to unknowingly leak connections to other databases. So, take
  # the additional step of telling ActiveRecord to check in all of the
  # current thread's connections between jobs.
  ::ActiveRecord::Base.clear_active_connections!
end