activerecord-mysql-reconnect 0.4.2 → 0.5.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 +4 -4
- data/.travis.yml +19 -3
- data/Appraisals +8 -0
- data/README.md +1 -1
- data/gemfiles/activerecord_6.0.gemfile +7 -0
- data/gemfiles/activerecord_master.gemfile +7 -0
- data/lib/activerecord/mysql/reconnect/connection_pool_ext.rb +11 -4
- data/lib/activerecord/mysql/reconnect/version.rb +1 -1
- data/spec/activerecord-mysql-reconnect_spec.rb +23 -8
- data/spec/spec_helper.rb +4 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bc18dd788aa14cabde46f1a2bc9c64aa9168dc2b3f0dad9ad1cb46a59be5168
|
4
|
+
data.tar.gz: a0ae45dcf3eb057079a0d20d5ef782df9a346467ef4b64fc6c63afd11652b841
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75535a38ab352914811c427a88323dcae8eee5d62dd789550cbb156969d54fd436c22f2222b6ef0aa4ca34b705a7fe497276b89018f6edd05b704d7ebc95060d
|
7
|
+
data.tar.gz: 118a316266cf5ec6d32fc168f70b9ecd85b242be259a6351be03591d6e6f9828dd5486457eb24857ed7d2124bdffe8214e074b77e72356ab0e1571712a27cde5
|
data/.travis.yml
CHANGED
@@ -2,9 +2,11 @@ dist: trusty
|
|
2
2
|
sudo: required
|
3
3
|
language: ruby
|
4
4
|
rvm:
|
5
|
-
- 2.3.
|
6
|
-
- 2.4.
|
7
|
-
- 2.5.
|
5
|
+
- 2.3.8
|
6
|
+
- 2.4.6
|
7
|
+
- 2.5.5
|
8
|
+
- 2.6.3
|
9
|
+
- 2.7.0
|
8
10
|
before_install:
|
9
11
|
- docker-compose up -d
|
10
12
|
- function mysql_ping { mysqladmin -u root -h 127.0.0.1 -ppassword ping > /dev/null 2> /dev/null; }
|
@@ -18,10 +20,24 @@ gemfile:
|
|
18
20
|
- gemfiles/activerecord_5.0.gemfile
|
19
21
|
- gemfiles/activerecord_5.1.gemfile
|
20
22
|
- gemfiles/activerecord_5.2.gemfile
|
23
|
+
- gemfiles/activerecord_6.0.gemfile
|
24
|
+
- gemfiles/activerecord_master.gemfile
|
21
25
|
env:
|
22
26
|
matrix:
|
23
27
|
- ACTIVERECORD_MYSQL_RECONNECT_ENGINE=InnoDB
|
24
28
|
- ACTIVERECORD_MYSQL_RECONNECT_ENGINE=MyISAM
|
29
|
+
jobs:
|
30
|
+
exclude:
|
31
|
+
- rvm: 2.3.8
|
32
|
+
gemfile: gemfiles/activerecord_6.0.gemfile
|
33
|
+
- rvm: 2.3.8
|
34
|
+
gemfile: gemfiles/activerecord_master.gemfile
|
35
|
+
- rvm: 2.4.6
|
36
|
+
gemfile: gemfiles/activerecord_6.0.gemfile
|
37
|
+
- rvm: 2.4.6
|
38
|
+
gemfile: gemfiles/activerecord_master.gemfile
|
39
|
+
- rvm: 2.7.0
|
40
|
+
gemfile: gemfiles/activerecord_4.2.gemfile
|
25
41
|
addons:
|
26
42
|
apt:
|
27
43
|
packages:
|
data/Appraisals
CHANGED
@@ -14,3 +14,11 @@ end
|
|
14
14
|
appraise "activerecord-5.2" do
|
15
15
|
gem "activerecord", "~> 5.2.0"
|
16
16
|
end
|
17
|
+
|
18
|
+
appraise "activerecord-6.0" do
|
19
|
+
gem "activerecord", "~> 6.0.2"
|
20
|
+
end
|
21
|
+
|
22
|
+
appraise "activerecord-master" do
|
23
|
+
gem "activerecord", git: "https://github.com/rails/rails.git"
|
24
|
+
end
|
data/README.md
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
module Activerecord::Mysql::Reconnect::NewConnectionWithRetry
|
2
2
|
def new_connection
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
if defined?(db_config)
|
4
|
+
Activerecord::Mysql::Reconnect.retryable(
|
5
|
+
:proc => proc { super },
|
6
|
+
:connection => db_config.configuration_hash
|
7
|
+
)
|
8
|
+
else
|
9
|
+
Activerecord::Mysql::Reconnect.retryable(
|
10
|
+
:proc => proc { super },
|
11
|
+
:connection => spec.config,
|
12
|
+
)
|
13
|
+
end
|
7
14
|
end
|
8
15
|
end
|
9
16
|
class ActiveRecord::ConnectionAdapters::ConnectionPool
|
@@ -461,10 +461,18 @@ describe 'activerecord-mysql-reconnect' do
|
|
461
461
|
|
462
462
|
context "when retry failed " do
|
463
463
|
specify do
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
464
|
+
if ActiveRecord::VERSION::MAJOR < 6
|
465
|
+
expect(ActiveRecord::Base.logger).to receive(:warn).with(warning_template % [
|
466
|
+
"MySQL server has gone away. Trying to reconnect in 0.5 seconds.",
|
467
|
+
"#{mysql_error}: Lost connection to MySQL server during query: SELECT `employees`.* FROM `employees` [ActiveRecord::StatementInvalid]",
|
468
|
+
])
|
469
|
+
else
|
470
|
+
expect(ActiveRecord::Base.logger).to receive(:warn).with(warning_template % [
|
471
|
+
"MySQL server has gone away. Trying to reconnect in 0.5 seconds.",
|
472
|
+
"#{mysql_error}: Lost connection to MySQL server during query [ActiveRecord::StatementInvalid]",
|
473
|
+
])
|
474
|
+
end
|
475
|
+
|
468
476
|
|
469
477
|
(1.0..4.5).step(0.5).each do |sec|
|
470
478
|
expect(ActiveRecord::Base.logger).to receive(:warn).with(warning_template % [
|
@@ -489,10 +497,17 @@ describe 'activerecord-mysql-reconnect' do
|
|
489
497
|
|
490
498
|
context "when retry succeeded" do
|
491
499
|
specify do
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
500
|
+
if ActiveRecord::VERSION::MAJOR < 6
|
501
|
+
expect(ActiveRecord::Base.logger).to receive(:warn).with(warning_template % [
|
502
|
+
"MySQL server has gone away. Trying to reconnect in 0.5 seconds.",
|
503
|
+
"#{mysql_error}: Lost connection to MySQL server during query: SELECT `employees`.* FROM `employees` [ActiveRecord::StatementInvalid]",
|
504
|
+
])
|
505
|
+
else
|
506
|
+
expect(ActiveRecord::Base.logger).to receive(:warn).with(warning_template % [
|
507
|
+
"MySQL server has gone away. Trying to reconnect in 0.5 seconds.",
|
508
|
+
"#{mysql_error}: Lost connection to MySQL server during query [ActiveRecord::StatementInvalid]",
|
509
|
+
])
|
510
|
+
end
|
496
511
|
|
497
512
|
expect(Employee.all.length).to eq 1000
|
498
513
|
MysqlServer.restart
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-mysql-reconnect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -117,6 +117,8 @@ files:
|
|
117
117
|
- gemfiles/activerecord_5.0.gemfile
|
118
118
|
- gemfiles/activerecord_5.1.gemfile
|
119
119
|
- gemfiles/activerecord_5.2.gemfile
|
120
|
+
- gemfiles/activerecord_6.0.gemfile
|
121
|
+
- gemfiles/activerecord_master.gemfile
|
120
122
|
- lib/activerecord-mysql-reconnect.rb
|
121
123
|
- lib/activerecord/mysql/reconnect.rb
|
122
124
|
- lib/activerecord/mysql/reconnect/abstract_mysql_adapter_ext.rb
|
@@ -150,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
152
|
- !ruby/object:Gem::Version
|
151
153
|
version: '0'
|
152
154
|
requirements: []
|
153
|
-
|
154
|
-
rubygems_version: 2.7.6
|
155
|
+
rubygems_version: 3.0.3
|
155
156
|
signing_key:
|
156
157
|
specification_version: 4
|
157
158
|
summary: It is the library to reconnect automatically when ActiveRecord is disconnected
|