Skip to content

Instantly share code, notes, and snippets.

@senny
Created August 15, 2013 18:48
Show Gist options
  • Save senny/6243581 to your computer and use it in GitHub Desktop.
Save senny/6243581 to your computer and use it in GitHub Desktop.
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