active_replicas 0.3.1 → 0.3.2
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: 173a69eb3b3d994aceb621ee0ab906ce00ffa351
|
4
|
+
data.tar.gz: 7a4b43fae106392d6ae07e572bcb4ab99bd7b0bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fa4f73e1a7edfcab0650b91627672de911677e90d516df5d095fdb7edb374fc896325557659b3b065398b8f9590a02f67e1d5b5986f19ddf884215c9cd5cf9f
|
7
|
+
data.tar.gz: 2e3592d77e410716166849b648a9295ac22430911a2363f81c658c032982009ae6662b6ffc6031a050821181810f4ae4270607473f9fafc7762f3e419b758036
|
@@ -51,6 +51,12 @@ module ActiveReplicas
|
|
51
51
|
proxy: self
|
52
52
|
end
|
53
53
|
|
54
|
+
def active_connection?
|
55
|
+
synchronize do
|
56
|
+
all_pools.any? { |pool| pool.active_connection? }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
54
60
|
def release_connection
|
55
61
|
synchronize do
|
56
62
|
each_pool &:release_connection
|
@@ -141,12 +147,14 @@ module ActiveReplicas
|
|
141
147
|
connection
|
142
148
|
end
|
143
149
|
|
144
|
-
|
145
|
-
|
150
|
+
# Returns an `Enumerable` over all the pools, primary and replicas, owned
|
151
|
+
# by this proxying pool.
|
152
|
+
def all_pools
|
153
|
+
[ @primary_pool ] + @replica_pools.values
|
154
|
+
end
|
146
155
|
|
147
|
-
|
148
|
-
|
149
|
-
end
|
156
|
+
def each_pool(&block)
|
157
|
+
all_pools.each &block
|
150
158
|
end
|
151
159
|
|
152
160
|
def pool_which_owns_connection(object_id)
|
@@ -29,6 +29,10 @@ module ActiveReplicas
|
|
29
29
|
proxying_connection_pool
|
30
30
|
end
|
31
31
|
|
32
|
+
def active_connections?
|
33
|
+
proxying_connection_pool.active_connection?
|
34
|
+
end
|
35
|
+
|
32
36
|
def clear_active_connections!
|
33
37
|
proxying_connection_pool.release_connection
|
34
38
|
end
|
@@ -37,6 +41,10 @@ module ActiveReplicas
|
|
37
41
|
proxying_connection_pool.clear_reloadable_connections!
|
38
42
|
end
|
39
43
|
|
44
|
+
def clear_all_connections!
|
45
|
+
proxying_connection_pool.disconnect!
|
46
|
+
end
|
47
|
+
|
40
48
|
# Cribbed from:
|
41
49
|
# https://github.com/rails/rails/blob/4-2-stable/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb#L568
|
42
50
|
def retrieve_connection(klass)
|
@@ -47,10 +55,6 @@ module ActiveReplicas
|
|
47
55
|
conn
|
48
56
|
end
|
49
57
|
|
50
|
-
def retrieve_connection_pool(klass)
|
51
|
-
proxying_connection_pool
|
52
|
-
end
|
53
|
-
|
54
58
|
def connected?(klass)
|
55
59
|
pool = retrieve_connection_pool klass
|
56
60
|
pool && pool.connected?
|
@@ -60,6 +64,10 @@ module ActiveReplicas
|
|
60
64
|
remove_proxying_connection_pool
|
61
65
|
end
|
62
66
|
|
67
|
+
def retrieve_connection_pool(klass)
|
68
|
+
proxying_connection_pool
|
69
|
+
end
|
70
|
+
|
63
71
|
def remove_proxying_connection_pool
|
64
72
|
if proxying_pool = @process_to_connection_pool.delete(Process.pid)
|
65
73
|
proxying_pool.automatic_reconnect = false
|
@@ -69,8 +69,9 @@ module ActiveReplicas
|
|
69
69
|
[
|
70
70
|
:add_transaction_record, :assume_migrated_upto_version,
|
71
71
|
:begin_transaction, :begin_db_transaction, :commit_db_transaction,
|
72
|
-
:
|
73
|
-
:
|
72
|
+
:create_database, :current_database, :disable_referential_integrity,
|
73
|
+
:drop_database, :foreign_keys, :indexes, :native_database_types,
|
74
|
+
:prefetch_primary_key?, :primary_key, :recreate_database,
|
74
75
|
:rollback_transaction, :rollback_db_transaction, :tables,
|
75
76
|
:table_exists?, :transaction, :transaction_state
|
76
77
|
]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_replicas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dirk Gadsden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|