active_record_host_pool 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'delegate'
|
2
|
+
require 'active_record'
|
3
|
+
require 'active_record/connection_adapters/mysql_adapter'
|
4
|
+
require 'active_record_host_pool/connection_adapter_mixin'
|
2
5
|
|
3
6
|
# this module sits in between ConnectionHandler and a bunch of different ConnectionPools (one per host).
|
4
7
|
# when a connection is requested, it goes like:
|
@@ -80,16 +83,9 @@ module ActiveRecordHostPool
|
|
80
83
|
|
81
84
|
def _connection_proxy_for(connection, database)
|
82
85
|
@connection_proxy_cache ||= {}
|
83
|
-
if !connection.respond_to?(:_host_pool_current_database)
|
84
|
-
connection.class.class_eval { include ActiveRecordHostPool::DatabaseSwitch }
|
85
|
-
end
|
86
86
|
key = [connection, database]
|
87
87
|
|
88
|
-
|
89
|
-
if !proxy
|
90
|
-
proxy = @connection_proxy_cache[key] = ActiveRecordHostPool::ConnectionProxy.new(connection, database)
|
91
|
-
end
|
92
|
-
proxy
|
88
|
+
@connection_proxy_cache[key] ||= ActiveRecordHostPool::ConnectionProxy.new(connection, database)
|
93
89
|
end
|
94
90
|
|
95
91
|
def _clear_connection_proxy_cache
|
@@ -97,3 +93,5 @@ module ActiveRecordHostPool
|
|
97
93
|
end
|
98
94
|
end
|
99
95
|
end
|
96
|
+
|
97
|
+
ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval { include ActiveRecordHostPool::DatabaseSwitch }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_host_pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 3
|
10
|
+
version: 0.5.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Osheroff
|