activerecord-refresh_connection 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcc81384ccdcb81089a22c49d4d5d253a1e7c0bd
|
4
|
+
data.tar.gz: 592f0dbcf3d4f5ac4923d9b8affbb6c6fccc7b2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38d112fac291d9ced98c09e309ca431c62c02c53e18a867abdad1cf987a986ed5c183be47ec6ef7788e337c4724af89e0e0af9a313c6e334d8a7f13c703df4a7
|
7
|
+
data.tar.gz: dac849aeb38f752370c3334904dcf1b172b7e512d8da44dd124f7c8437391e451e329c2c48f7a4de8238f829803da30b5a0acafaa6c81f8723ce21c91ccd2f26
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "activerecord-refresh_connection"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.4"
|
8
8
|
spec.authors = ["Naotoshi Seo"]
|
9
9
|
spec.email = ["sonots@gmail.com"]
|
10
10
|
spec.summary = %q{Refresh ActiveRecord connection on each rack request}
|
@@ -16,22 +16,28 @@ module ActiveRecord
|
|
16
16
|
|
17
17
|
response = @app.call(env)
|
18
18
|
|
19
|
-
clear_connections = should_clear_connections? && !testing
|
20
|
-
|
21
19
|
response[2] = ::Rack::BodyProxy.new(response[2]) do
|
22
20
|
# disconnect all connections on the connection pool
|
23
|
-
|
21
|
+
clear_connections unless testing
|
24
22
|
end
|
25
23
|
|
26
24
|
response
|
27
25
|
rescue Exception
|
28
|
-
|
26
|
+
clear_connections unless testing
|
29
27
|
raise
|
30
28
|
end
|
31
29
|
|
32
30
|
private
|
33
31
|
|
34
|
-
def
|
32
|
+
def clear_connections
|
33
|
+
if should_clear_all_connections?
|
34
|
+
ActiveRecord::Base.clear_all_connections!
|
35
|
+
else
|
36
|
+
ActiveRecord::Base.clear_active_connections!
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def should_clear_all_connections?
|
35
41
|
return true if max_requests <= 1
|
36
42
|
|
37
43
|
@mutex.synchronize do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-refresh_connection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|