Skip to content

Instantly share code, notes, and snippets.

@mrzor
mrzor / mysql2_connection_pool.rb
Created April 15, 2011 14:03
a connection pool for eventmachine & mysql2 with batch-query support (allows async transactions)
require 'mysql2'
require 'mysql2/em'
class MysqlConnectionPool
def initialize(conf)
@pool_size = conf[:size] || 10
@query_queue = EM::Queue.new
@connections = {}
start_queue conf