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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 902e5e0cb2f51303355efa11fe7d25d357d6c9560310cab1e3e6bc5c0ad1758b
4
- data.tar.gz: 9584c62c0572915b4de0aff99b2449a787c6236d3828e3858b6a6c2079ef1882
3
+ metadata.gz: 48f4b996cc1630787e9d61bf8f138deb1fe1b1162ba242ac860802287750a807
4
+ data.tar.gz: 1980813b23f714d9e7460df499307b3dfb06d3cc90c44226f52f68fc2c9f3e72
5
5
  SHA512:
6
- metadata.gz: 400906a1082b28c51d7bbcd3efffed956e4e26ce46c8bc2e71a73431ce1028eafcbfef06a0b3a220647ea3e5865b1d9ac8b2dd34960bba76d7ca059339daaf0a
7
- data.tar.gz: 8094cbe8a0497f5d16cb7caa27953d4e78e2945cd46f53e00912654b2fff7cb447c8dc323b0faeebc74f3c425bd9e6a2b86f4546485e46171616a3cd2b6f10e3
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordHostPool
4
- VERSION = "0.12.0"
4
+ VERSION = "0.13.0"
5
5
  end
@@ -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.12.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-21 00:00:00.000000000 Z
14
+ date: 2019-08-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activerecord