active_replicas 0.3.1 → 0.3.2

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: 568a0386c779f2f367053cd393c1c65de920c961
4
- data.tar.gz: e4b35b5285b54c8138d4a870c600c4d0a9f27d4f
3
+ metadata.gz: 173a69eb3b3d994aceb621ee0ab906ce00ffa351
4
+ data.tar.gz: 7a4b43fae106392d6ae07e572bcb4ab99bd7b0bb
5
5
  SHA512:
6
- metadata.gz: cde5776cce49b5f8b3fc7ea05b88dda83834a323374d49cfb349b5fc5580da2521e2f08e9222283ea6feaa212c219a89f089289761d72acb89259380ebc469d3
7
- data.tar.gz: bde2b2bfd056ea9de4a9816277e73432019804a4b90ad891b99544e02d9b301bd7dee9173cf7e7c87e6b2fbbd0ed9ec99107f071eaeda62c0d6da4be9396b613
6
+ metadata.gz: 4fa4f73e1a7edfcab0650b91627672de911677e90d516df5d095fdb7edb374fc896325557659b3b065398b8f9590a02f67e1d5b5986f19ddf884215c9cd5cf9f
7
+ data.tar.gz: 2e3592d77e410716166849b648a9295ac22430911a2363f81c658c032982009ae6662b6ffc6031a050821181810f4ae4270607473f9fafc7762f3e419b758036
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- active_replicas (0.3.1)
4
+ active_replicas (0.3.2)
5
5
  concurrent-ruby (~> 1.0)
6
6
 
7
7
  GEM
@@ -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
- def each_pool
145
- yield @primary_pool
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
- @replica_pools.each do |_name, pool|
148
- yield pool
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
- :disable_referential_integrity, :foreign_keys, :indexes,
73
- :native_database_types, :prefetch_primary_key?, :primary_key,
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
  ]
@@ -1,3 +1,3 @@
1
1
  module ActiveReplicas
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
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.1
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-23 00:00:00.000000000 Z
11
+ date: 2016-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby