Permalink
Browse files

Proxy more of AR's ConnectionPool API

  • Loading branch information...
mperham committed Feb 11, 2011
1 parent 3c91463 commit 300d7adb3236998c47eed4a7ae4787fbc61c4fc0
Showing with 20 additions and 3 deletions.
  1. +1 −0 data_fabric.gemspec
  2. +12 −3 lib/data_fabric/connection_proxy.rb
  3. +7 −0 test/connection_test.rb
View
@@ -22,5 +22,6 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.description = s.summary = %q{Sharding and replication support for ActiveRecord 2.x}
s.add_development_dependency(%q<flexmock>, [">= 0"])
+ s.add_development_dependency(%q<sqlite3>, [">= 0"])
end
@@ -22,21 +22,30 @@ class PoolProxy
def initialize(proxy)
@proxy = proxy
end
+
def connection
@proxy
end
- def release_connection
- DataFabric.logger.debug { 'data_fabric does not implement release_connection' }
- end
+
def spec
@proxy.spec
end
+
def with_connection
yield @proxy
end
+
def connected?
@proxy.connected?
end
+
+ %w(disconnect! release_connection clear_reloadable_connections! clear_stale_cached_connections! verify_active_connections!).each do |name|
+ define_method(name.to_sym) do
+ @proxy.shard_pools.values.each do |pool|
+ pool.send(name.to_sym)
+ end
+ end
+ end
end
class ConnectionProxy
View
@@ -100,7 +100,14 @@ def test_enchilada
TheWholeEnchilada.transaction do
mmmm.save!
end
+ TheWholeEnchilada.verify_active_connections!
+ TheWholeEnchilada.clear_active_connections!
+ TheWholeEnchilada.clear_all_connections!
end
+
+ TheWholeEnchilada.verify_active_connections!
+ TheWholeEnchilada.clear_active_connections!
+ TheWholeEnchilada.clear_all_connections!
end
private

0 comments on commit 300d7ad

Please sign in to comment.