active_record_host_pool 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +8 -0
- data/lib/active_record_host_pool/pool_proxy.rb +28 -0
- data/lib/active_record_host_pool/version.rb +1 -1
- data/test/test_arhp.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48f4b996cc1630787e9d61bf8f138deb1fe1b1162ba242ac860802287750a807
|
4
|
+
data.tar.gz: 1980813b23f714d9e7460df499307b3dfb06d3cc90c44226f52f68fc2c9f3e72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b0234af923f2818200c0f3a28a8c56c98d89ba6d640e9aeb9038fc8ebb504d6030b22a7675e920c47c0c2aedf25a6426959f0f59d0a0ab3e4047ebaad1ae23a
|
7
|
+
data.tar.gz: 4f03daf7d20486e837bf28d03b5032c48db403bb9075c00ea181c2a57b8070b7c68cd9886a252d41ad03ff5a54ccc5b095033636fd4c5f75359fde52d67c17a6
|
data/Readme.md
CHANGED
@@ -24,6 +24,14 @@ You need a local user called 'john-doe'.
|
|
24
24
|
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX ON *.* TO 'john-doe'@'localhost';
|
25
25
|
FLUSH PRIVILEGES;
|
26
26
|
|
27
|
+
With mysql running locally, run
|
28
|
+
|
29
|
+
BUNDLE_GEMFILE=gemfiles/rails5.2.gemfile bundle exec rake test
|
30
|
+
|
31
|
+
Or
|
32
|
+
|
33
|
+
BUNDLE_GEMFILE=gemfiles/rails5.2.gemfile ruby test/test_arhp.rb --seed 19911 --verbose
|
34
|
+
|
27
35
|
## Copyright
|
28
36
|
|
29
37
|
Copyright (c) 2011 Zendesk. See MIT-LICENSE for details.
|
@@ -84,6 +84,34 @@ module ActiveRecordHostPool
|
|
84
84
|
_clear_connection_proxy_cache
|
85
85
|
end
|
86
86
|
|
87
|
+
def release_connection(owner_thread = Thread.current)
|
88
|
+
p = _connection_pool(false)
|
89
|
+
return unless p
|
90
|
+
|
91
|
+
p.release_connection(owner_thread)
|
92
|
+
end
|
93
|
+
|
94
|
+
def flush!
|
95
|
+
p = _connection_pool(false)
|
96
|
+
return unless p
|
97
|
+
|
98
|
+
p.flush!
|
99
|
+
end
|
100
|
+
|
101
|
+
def discard!
|
102
|
+
p = _connection_pool(false)
|
103
|
+
return unless p
|
104
|
+
|
105
|
+
p.discard!
|
106
|
+
|
107
|
+
# All connections in the pool (even if they're currently
|
108
|
+
# leased!) have just been discarded, along with the pool itself.
|
109
|
+
# Any further interaction with the pool (except #spec and #schema_cache)
|
110
|
+
# is undefined.
|
111
|
+
# Remove the connection for the given key so a new one can be created in its place
|
112
|
+
_connection_pools.delete(_pool_key)
|
113
|
+
end
|
114
|
+
|
87
115
|
private
|
88
116
|
|
89
117
|
def rescuable_errors
|
data/test/test_arhp.rb
CHANGED
@@ -13,6 +13,23 @@ class ActiveRecordHostPoolTest < Minitest::Test
|
|
13
13
|
Phenix.burn!
|
14
14
|
end
|
15
15
|
|
16
|
+
def test_process_forking_with_connections
|
17
|
+
# Ensure we have a connection already
|
18
|
+
assert_equal(true, ActiveRecord::Base.connected?)
|
19
|
+
|
20
|
+
# Verify that when we fork, the process doesn't crash
|
21
|
+
pid = Process.fork do
|
22
|
+
if ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 2
|
23
|
+
assert_equal(false, ActiveRecord::Base.connected?) # New to Rails 5.2
|
24
|
+
else
|
25
|
+
assert_equal(true, ActiveRecord::Base.connected?)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
Process.wait(pid)
|
29
|
+
# Cleanup any connections we may have left around
|
30
|
+
ActiveRecord::Base.connection_handler.clear_all_connections!
|
31
|
+
end
|
32
|
+
|
16
33
|
def test_models_with_matching_hosts_should_share_a_connection
|
17
34
|
assert_equal(Test1.connection.raw_connection, Test2.connection.raw_connection)
|
18
35
|
assert_equal(Test3.connection.raw_connection, Test4.connection.raw_connection)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_host_pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Quorning
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-08-
|
14
|
+
date: 2019-08-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activerecord
|