Created
August 15, 2013 18:48
-
-
Save senny/6243581 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module QC | |
module Rails | |
class Job < ActiveRecord::Base | |
self.table_name = "queue_classic_jobs" | |
end | |
class Conn < QC::Conn | |
attr_reader :ar_conn | |
def initialize(ar_conn) | |
@ar_conn = ar_conn | |
@c = ar_conn.raw_connection | |
end | |
end | |
class Pool < QC::Pool | |
def initialize(*) | |
# configuration is done via Active Record | |
end | |
def drain! | |
ar_pool.disconnect! | |
end | |
def checkout(new_on_empty=false) | |
# use `connection` instead of `checkout` to reuse the current thread's connection | |
Rails::Conn.new ar_pool.connection | |
end | |
def checkin(conn) | |
ar_pool.checkin(conn.ar_conn) | |
end | |
def ar_pool | |
QC::Rails::Job.connection_handler.retrieve_connection_pool(QC::Rails::Job) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment