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: 12543c609a56645522b185ac709b69e9acfc3a92
4
- data.tar.gz: 8b3009b7ba30137204b742ec39794e1e13702036
3
+ metadata.gz: f8592bbc517a85a61aabac19a2af8d8c2b12c564
4
+ data.tar.gz: a7223d50e939cce06bd3d2d6238f4389870b132f
5
5
  SHA512:
6
- metadata.gz: b1409e66dabb4e520b0f903d60749681372177b3aaa69beb8a4b07467eb74db08c0d118d7831d5aee1ae633715eb11d1a264697a298537e760d88bf478a6599c
7
- data.tar.gz: da45f12c15c38eb999f8de4d267933301040a0dd949e96b982c518236077d9a532df21d10a26318edfc0008a9a38144cfa69c9264ecad8893ecb2ec5d32287ba
6
+ metadata.gz: ee686e5c728faa23dc786550f4ee7629a9eada19e9fb286a88cf15691186ece875e13a89655de328b6b0fd99a358a388023a645489854a72780961ed87a615ac
7
+ data.tar.gz: e2f21b79bfa1c9fc56365e6c508d125881ff303b3efa43b1c43db29ff83d8b0a2d4787376ef4c3644ce57003444984036521e1d4b50f69e77a389cfd987fea9d
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'rake', '~> 10.0'
24
24
  spec.add_development_dependency 'rspec', '~> 3.0'
25
25
  spec.add_development_dependency 'appraisal', '~> 2.1'
26
+ spec.add_development_dependency 'sqlite3', '~> 1.3'
26
27
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- active_replicas (0.1.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.with_indifferent_access
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, _spec)
19
- raise "ActiveReplicas cannot establish connection for #{owner.name}"
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 pool = @process_to_connection_pool.delete(Process.pid)
47
- pool.automatic_reconnect = false
48
- pool.disconnect!
49
- pool.spec.config
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
 
@@ -1,3 +1,3 @@
1
1
  module ActiveReplicas
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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: