ar_mysql_flexmaster 0.5.0 → 0.6.0
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: 8d979b832a9129feb067d6993efc2ac5fc58ae92
|
|
4
|
+
data.tar.gz: 600daab5842bf3edebc12e17ede751032b3c3c53
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20975216d3400b8755321d8e9de0f506e3a661de0e698fb9e89f54ec647017700c9596b3f341a0acd7b059d4721d10b129b4af3439b5c9ff3eece408f6ea153b
|
|
7
|
+
data.tar.gz: eedcce97ab154e6b2886fd51cf8cda509b3e77b382ccd84df9333e66805ed3b4a2da79ed2d274f9f1c880fbf69700fbec842719d34eaa749fd19f4d3f8e7c211
|
data/ar_mysql_flexmaster.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
|
12
12
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
13
13
|
gem.name = "ar_mysql_flexmaster"
|
|
14
14
|
gem.require_paths = ["lib"]
|
|
15
|
-
gem.version = "0.
|
|
15
|
+
gem.version = "0.6.0"
|
|
16
16
|
|
|
17
17
|
gem.add_runtime_dependency("mysql2")
|
|
18
18
|
gem.add_runtime_dependency("activerecord")
|
|
@@ -28,16 +28,18 @@ module ActiveRecord
|
|
|
28
28
|
class TooManyMastersException < StandardError; end
|
|
29
29
|
class NoServerAvailableException < StandardError; end
|
|
30
30
|
|
|
31
|
-
CHECK_EVERY_N_SELECTS
|
|
32
|
-
DEFAULT_CONNECT_TIMEOUT
|
|
33
|
-
|
|
31
|
+
CHECK_EVERY_N_SELECTS = 10
|
|
32
|
+
DEFAULT_CONNECT_TIMEOUT = 1
|
|
33
|
+
DEFAULT_CONNECT_ATTEMPTS = 3
|
|
34
|
+
DEFAULT_TX_HOLD_TIMEOUT = 5
|
|
34
35
|
|
|
35
36
|
def initialize(logger, config)
|
|
36
37
|
@select_counter = 0
|
|
37
38
|
@config = config
|
|
38
39
|
@rw = config[:slave] ? :read : :write
|
|
39
|
-
@tx_hold_timeout
|
|
40
|
-
@connection_timeout
|
|
40
|
+
@tx_hold_timeout = @config[:tx_hold_timeout] || DEFAULT_TX_HOLD_TIMEOUT
|
|
41
|
+
@connection_timeout = @config[:connection_timeout] || DEFAULT_CONNECT_TIMEOUT
|
|
42
|
+
@connection_attempts = @config[:connection_attempts] || DEFAULT_CONNECT_ATTEMPTS
|
|
41
43
|
|
|
42
44
|
connection = find_correct_host(@rw)
|
|
43
45
|
|
|
@@ -245,6 +247,7 @@ module ActiveRecord
|
|
|
245
247
|
end
|
|
246
248
|
|
|
247
249
|
def initialize_connection(host, port)
|
|
250
|
+
attempts = 1
|
|
248
251
|
begin
|
|
249
252
|
Timeout::timeout(@connection_timeout) do
|
|
250
253
|
cfg = @config.merge(:host => host, :port => port)
|
|
@@ -252,12 +255,14 @@ module ActiveRecord
|
|
|
252
255
|
cx.query_options.merge!(:as => :array)
|
|
253
256
|
end
|
|
254
257
|
end
|
|
255
|
-
rescue Mysql2::Error => e
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
rescue Mysql2::Error, Timeout::Error => e
|
|
259
|
+
if attempts < @connection_attempts
|
|
260
|
+
attempts += 1
|
|
261
|
+
retry
|
|
262
|
+
else
|
|
263
|
+
collected_errors << e
|
|
264
|
+
nil
|
|
265
|
+
end
|
|
261
266
|
end
|
|
262
267
|
end
|
|
263
268
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ar_mysql_flexmaster
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Osheroff
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-01-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mysql2
|