active_replicas 0.1.2 → 0.1.3
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8592bbc517a85a61aabac19a2af8d8c2b12c564
|
4
|
+
data.tar.gz: a7223d50e939cce06bd3d2d6238f4389870b132f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee686e5c728faa23dc786550f4ee7629a9eada19e9fb286a88cf15691186ece875e13a89655de328b6b0fd99a358a388023a645489854a72780961ed87a615ac
|
7
|
+
data.tar.gz: e2f21b79bfa1c9fc56365e6c508d125881ff303b3efa43b1c43db29ff83d8b0a2d4787376ef4c3644ce57003444984036521e1d4b50f69e77a389cfd987fea9d
|
data/active_replicas.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
active_replicas (0.1.
|
4
|
+
active_replicas (0.1.3)
|
5
5
|
concurrent-ruby (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -114,6 +114,7 @@ GEM
|
|
114
114
|
actionpack (>= 4.0)
|
115
115
|
activesupport (>= 4.0)
|
116
116
|
sprockets (>= 3.0.0)
|
117
|
+
sqlite3 (1.3.12)
|
117
118
|
thor (0.19.1)
|
118
119
|
thread_safe (0.3.5)
|
119
120
|
tzinfo (1.2.2)
|
@@ -129,6 +130,7 @@ DEPENDENCIES
|
|
129
130
|
rails (~> 4.0)
|
130
131
|
rake (~> 10.0)
|
131
132
|
rspec (~> 3.0)
|
133
|
+
sqlite3 (~> 1.3)
|
132
134
|
|
133
135
|
BUNDLED WITH
|
134
136
|
1.13.6
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support/hash_with_indifferent_access'
|
2
|
+
|
1
3
|
module ActiveReplicas
|
2
4
|
# Manages connection pools to the primary and replica databases. Returns
|
3
5
|
# proxy connection instances from those pools on request.
|
@@ -30,7 +32,7 @@ module ActiveReplicas
|
|
30
32
|
|
31
33
|
# Turns a hash configuration into a `ConnectionSpecification` that can
|
32
34
|
# be passed to a `ConnectionPool`.
|
33
|
-
spec = @@resolver.spec config_spec
|
35
|
+
spec = @@resolver.spec ActiveSupport::HashWithIndifferentAccess.new(config_spec)
|
34
36
|
|
35
37
|
ActiveRecord::ConnectionAdapters::ConnectionPool.new spec
|
36
38
|
end
|
@@ -75,6 +77,12 @@ module ActiveReplicas
|
|
75
77
|
@current_pool
|
76
78
|
end
|
77
79
|
|
80
|
+
def automatic_reconnect=(new_value)
|
81
|
+
each_pool do |pool|
|
82
|
+
pool.automatic_reconnect = new_value
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
78
86
|
# Additional methods
|
79
87
|
# ==================
|
80
88
|
|
@@ -15,8 +15,8 @@ module ActiveReplicas
|
|
15
15
|
@process_to_connection_pool = Concurrent::Map.new
|
16
16
|
end
|
17
17
|
|
18
|
-
def establish_connection(owner,
|
19
|
-
|
18
|
+
def establish_connection(owner, spec)
|
19
|
+
proxying_connection_pool
|
20
20
|
end
|
21
21
|
|
22
22
|
def clear_active_connections!
|
@@ -43,10 +43,10 @@ module ActiveReplicas
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def remove_connection(owner_klass)
|
46
|
-
if
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
if proxying_pool = @process_to_connection_pool.delete(Process.pid)
|
47
|
+
proxying_pool.automatic_reconnect = false
|
48
|
+
proxying_pool.disconnect!
|
49
|
+
proxying_pool.primary_pool.spec.config
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_replicas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dirk Gadsden
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.3'
|
83
97
|
description: Hooks into ActiveRecord to automatically sends reads to read replicas
|
84
98
|
and writes to primary database.
|
85
99
|
email:
|