active_record_mysql_xverify 0.2.2 → 0.3.0

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
  SHA256:
3
- metadata.gz: 2a46880b7feb5ba8ae7bff088286906fed643d0a4e675e427f3f15f3c8a23acf
4
- data.tar.gz: 33b49e0e82fc7895a7ecdd29c8d49b3c34a28900377628e7d1f4c899c6ef7871
3
+ metadata.gz: 8916472485098dffa64b7ee6eac7e6dba77ef47c11a5a6b40962cbc1a58e9876
4
+ data.tar.gz: 521ce8d4c2e7cc89a9224efd0a2429c2f4eaf82b7a0f717313497ff71144886f
5
5
  SHA512:
6
- metadata.gz: d480ed34d3c86dc5f62d082e86161c63b1478e8d8dbb185c25de527b48d8644d9eb6a9e56e94fc7525ee9700c28e156788811256e1e1f05b68dbfb8bdc9a912a
7
- data.tar.gz: 2106e3d52403afc79bad9a27b0cecc0f2c174cc4f454d674393258288f6b3d370e215309b27b0cac6c39bbf7bb19c0deedcfc55a14be147a5e15abc846feab62
6
+ metadata.gz: 0a6e9a7be89d458a1eb9a95da5e2bbc5786a8ab05443273a191308840b0550303c6370fb6c29fc1af30cbd36ba14a0cc074b2188d32c97db4482f6dabb2b20d2
7
+ data.tar.gz: bcd6ae93459bf26aa3b54c0139a4980461c46910764ef72c83d1d68cf00b1408519a61e16ebb75a22160ba3184a8e78553c367ff39cc2a3c064c2d12fb7fec26
@@ -0,0 +1,40 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ services:
11
+ mysql:
12
+ image: mysql:5.7
13
+ ports:
14
+ - 3306:3306
15
+ env:
16
+ MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
17
+ options: --health-cmd "mysqladmin ping -h localhost" --health-interval 1s --health-timeout 3s --health-retries 60
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby:
22
+ - 2.7
23
+ - 3.0
24
+ - 3.1
25
+ - 3.2
26
+ gemfile:
27
+ - gemfiles/ar60.gemfile
28
+ - gemfiles/ar61.gemfile
29
+ - gemfiles/ar70.gemfile
30
+ env:
31
+ DATABASE_HOST: 127.0.0.1
32
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
33
+ steps:
34
+ - uses: actions/checkout@v3
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+ bundler-cache: true
39
+ - run: bundle install
40
+ - run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,7 +1,10 @@
1
1
  AllCops:
2
2
  Exclude:
3
3
  - "gemfiles/**/*"
4
- TargetRubyVersion: 2.4
4
+ - "vendor/bundle/**/*"
5
+ TargetRubyVersion: 2.7
6
+ SuggestExtensions: false
7
+ NewCops: enable
5
8
  Metrics/BlockLength:
6
9
  Enabled: false
7
10
  Metrics/LineLength:
@@ -14,80 +17,5 @@ Style/Documentation:
14
17
  Enabled: false
15
18
  Style/TrailingCommaInHashLiteral:
16
19
  EnforcedStyleForMultiline: consistent_comma
17
- Gemspec/RequiredRubyVersion:
20
+ Gemspec/DevelopmentDependencies:
18
21
  Enabled: false
19
-
20
- Layout/EmptyLinesAroundAttributeAccessor:
21
- Enabled: true
22
- Layout/SpaceAroundMethodCallOperator:
23
- Enabled: true
24
- Lint/BinaryOperatorWithIdenticalOperands:
25
- Enabled: true
26
- Lint/DeprecatedOpenSSLConstant:
27
- Enabled: true
28
- Lint/DuplicateElsifCondition:
29
- Enabled: true
30
- Lint/DuplicateRescueException:
31
- Enabled: true
32
- Lint/EmptyConditionalBody:
33
- Enabled: true
34
- Lint/FloatComparison:
35
- Enabled: true
36
- Lint/MissingSuper:
37
- Enabled: true
38
- Lint/MixedRegexpCaptureTypes:
39
- Enabled: true
40
- Lint/OutOfRangeRegexpRef:
41
- Enabled: true
42
- Lint/RaiseException:
43
- Enabled: true
44
- Lint/SelfAssignment:
45
- Enabled: true
46
- Lint/StructNewOverride:
47
- Enabled: true
48
- Lint/TopLevelReturnWithArgument:
49
- Enabled: true
50
- Lint/UnreachableLoop:
51
- Enabled: true
52
- Style/AccessorGrouping:
53
- Enabled: true
54
- Style/ArrayCoercion:
55
- Enabled: true
56
- Style/BisectedAttrAccessor:
57
- Enabled: true
58
- Style/CaseLikeIf:
59
- Enabled: true
60
- Style/ExplicitBlockArgument:
61
- Enabled: true
62
- Style/ExponentialNotation:
63
- Enabled: true
64
- Style/GlobalStdStream:
65
- Enabled: true
66
- Style/HashAsLastArrayItem:
67
- Enabled: true
68
- Style/HashEachMethods:
69
- Enabled: true
70
- Style/HashLikeCase:
71
- Enabled: true
72
- Style/HashTransformKeys:
73
- Enabled: true
74
- Style/HashTransformValues:
75
- Enabled: true
76
- Style/OptionalBooleanParameter:
77
- Enabled: true
78
- Style/RedundantAssignment:
79
- Enabled: true
80
- Style/RedundantFetchBlock:
81
- Enabled: true
82
- Style/RedundantFileExtensionInRequire:
83
- Enabled: true
84
- Style/RedundantRegexpCharacterClass:
85
- Enabled: true
86
- Style/RedundantRegexpEscape:
87
- Enabled: true
88
- Style/SingleArgumentDig:
89
- Enabled: true
90
- Style/SlicingWithRange:
91
- Enabled: true
92
- Style/StringConcatenation:
93
- Enabled: true
data/Appraisals CHANGED
@@ -1,22 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'ar42' do
4
- gem 'activerecord', '~> 4.2.10'
5
- gem 'mysql2', '< 0.5'
6
- end
7
-
8
- appraise 'ar50' do
9
- gem 'activerecord', '~> 5.0.7'
10
- end
11
-
12
- appraise 'ar51' do
13
- gem 'activerecord', '~> 5.1.6'
3
+ appraise 'ar60' do
4
+ gem 'activerecord', '~> 6.0.3'
14
5
  end
15
6
 
16
- appraise 'ar52' do
17
- gem 'activerecord', '~> 5.2.1'
7
+ appraise 'ar61' do
8
+ gem 'activerecord', '~> 6.1'
18
9
  end
19
10
 
20
- appraise 'ar60' do
21
- gem 'activerecord', '~> 6.0.3'
11
+ appraise 'ar70' do
12
+ gem 'activerecord', '~> 7.0'
22
13
  end
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM rubylang/ruby:2.5-bionic
1
+ FROM rubylang/ruby:2.7
2
2
 
3
3
  RUN apt-get update && \
4
4
  apt-get install -y \
@@ -6,8 +6,11 @@ RUN apt-get update && \
6
6
  libmysqlclient-dev \
7
7
  rubygems
8
8
 
9
- COPY ./ /mnt/
10
9
  WORKDIR /mnt
10
+ COPY Gemfile* ./
11
+ COPY lib/active_record_mysql_xverify/version.rb ./lib/active_record_mysql_xverify/
12
+ COPY Appraisals ./
13
+ COPY activerecord_mysql_xverify.gemspec ./
11
14
  RUN gem update bundler -f && \
12
15
  bundle install && \
13
16
  bundle exec appraisal install
data/README.md CHANGED
@@ -7,7 +7,7 @@ cf. https://github.com/brianmario/mysql2/issues/948
7
7
  **Note: This library does not retry queries. Just reconnect.**
8
8
 
9
9
  [![Gem Version](https://badge.fury.io/rb/active_record_mysql_xverify.svg)](http://badge.fury.io/rb/active_record_mysql_xverify)
10
- [![Build Status](https://travis-ci.org/winebarrel/active_record_mysql_xverify.svg?branch=master)](https://travis-ci.org/winebarrel/active_record_mysql_xverify)
10
+ [![Build Status](https://github.com/winebarrel/active_record_mysql_xverify/workflows/test/badge.svg?branch=master)](https://github.com/winebarrel/active_record_mysql_xverify/actions)
11
11
 
12
12
  ## How it works
13
13
 
@@ -53,6 +53,8 @@ end
53
53
  # Default: ->(conn) { conn.ping }
54
54
 
55
55
  ActiveRecordMysqlXverify.handle_if = ->(config) do
56
+ # Check Aurora writer node
57
+ # NOTE: DO NOT verify reader node connection
56
58
  config[:host] == '127.0.0.1'
57
59
  end
58
60
  # Default: ->(_) { true }
@@ -132,11 +134,10 @@ Completed 302 Found in 150ms (ActiveRecord: 145.2ms)
132
134
 
133
135
  ## Test
134
136
 
135
- ## Test
136
-
137
137
  ```sh
138
- docker-compose build
139
- docker-compose run client bundle exec appraisal ar60 rake
138
+ docker compose up -d
139
+ docker compose build client
140
+ docker compose run --rm client appraisal ar60 rake
140
141
  ```
141
142
 
142
143
  ## Related links
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.bindir = 'exe'
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ['lib']
26
+ spec.required_ruby_version = '>= 2.7'
26
27
 
27
28
  spec.add_dependency 'activerecord'
28
29
  spec.add_dependency 'mysql2'
@@ -30,5 +31,8 @@ Gem::Specification.new do |spec|
30
31
  spec.add_development_dependency 'bundler'
31
32
  spec.add_development_dependency 'rake'
32
33
  spec.add_development_dependency 'rspec', '~> 3.0'
33
- spec.add_development_dependency 'rubocop'
34
+ spec.add_development_dependency 'rubocop', '>= 1.8.0'
35
+ spec.add_development_dependency 'rubocop-rake'
36
+ spec.add_development_dependency 'rubocop-rspec'
37
+ spec.metadata['rubygems_mfa_required'] = 'true'
34
38
  end
data/docker-compose.yml CHANGED
@@ -1,4 +1,3 @@
1
- version: "3.8"
2
1
  services:
3
2
  client:
4
3
  build: .
@@ -6,6 +5,8 @@ services:
6
5
  - ./:/mnt
7
6
  depends_on:
8
7
  - mysql
8
+ profiles:
9
+ - extra
9
10
  mysql:
10
11
  image: mysql:5.7
11
12
  environment:
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.2.1"
5
+ gem "activerecord", "~> 6.1"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.0.7"
5
+ gem "activerecord", "~> 7.0"
6
6
 
7
7
  gemspec path: "../"
@@ -2,7 +2,14 @@
2
2
 
3
3
  module ActiveRecordMysqlXverify
4
4
  module ErrorHandler
5
- def execute(*)
5
+ def execute(*, **)
6
+ super
7
+ rescue StandardError
8
+ _flag_extend_verify!
9
+ raise
10
+ end
11
+
12
+ def raw_execute(*, **)
6
13
  super
7
14
  rescue StandardError
8
15
  _flag_extend_verify!
@@ -5,10 +5,10 @@ module ActiveRecordMysqlXverify
5
5
  class << self
6
6
  def mysql2_connection_info(conn)
7
7
  thread_id = begin
8
- conn.thread_id
9
- rescue StandardError
10
- nil
11
- end
8
+ conn.thread_id
9
+ rescue StandardError
10
+ nil
11
+ end
12
12
 
13
13
  "host=#{conn.query_options[:host]}, database=#{conn.query_options[:database]}, " \
14
14
  "username=#{conn.query_options[:username]}, thread_id=#{thread_id}"
@@ -5,14 +5,14 @@ module ActiveRecordMysqlXverify
5
5
  def active?
6
6
  if _extend_verify?
7
7
  is_active = begin
8
- verifier = ActiveRecordMysqlXverify.verify
9
- verifier.call(@connection)
10
- rescue StandardError => e
11
- ActiveRecordMysqlXverify.logger.warn("Connection verification failed: #{_build_verify_error_message(e)}")
12
- false
13
- ensure
14
- Thread.current[ActiveRecordMysqlXverify::EXTEND_VERIFY_FLAG] = false
15
- end
8
+ verifier = ActiveRecordMysqlXverify.verify
9
+ verifier.call(@connection)
10
+ rescue StandardError => e
11
+ ActiveRecordMysqlXverify.logger.warn("Connection verification failed: #{_build_verify_error_message(e)}")
12
+ false
13
+ ensure
14
+ Thread.current[ActiveRecordMysqlXverify::EXTEND_VERIFY_FLAG] = false
15
+ end
16
16
 
17
17
  unless is_active
18
18
  ActiveRecordMysqlXverify.logger.info(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordMysqlXverify
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_mysql_xverify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-13 00:00:00.000000000 Z
11
+ date: 2023-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -96,6 +96,34 @@ dependencies:
96
96
  version: '3.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 1.8.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.8.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rspec
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
129
  - - ">="
@@ -116,10 +144,10 @@ executables: []
116
144
  extensions: []
117
145
  extra_rdoc_files: []
118
146
  files:
147
+ - ".github/workflows/test.yml"
119
148
  - ".gitignore"
120
149
  - ".rspec"
121
150
  - ".rubocop.yml"
122
- - ".travis.yml"
123
151
  - Appraisals
124
152
  - Dockerfile
125
153
  - Gemfile
@@ -131,11 +159,9 @@ files:
131
159
  - bin/setup
132
160
  - docker-compose.yml
133
161
  - gemfiles/.bundle/config
134
- - gemfiles/ar42.gemfile
135
- - gemfiles/ar50.gemfile
136
- - gemfiles/ar51.gemfile
137
- - gemfiles/ar52.gemfile
138
162
  - gemfiles/ar60.gemfile
163
+ - gemfiles/ar61.gemfile
164
+ - gemfiles/ar70.gemfile
139
165
  - lib/active_record_mysql_xverify.rb
140
166
  - lib/active_record_mysql_xverify/config.rb
141
167
  - lib/active_record_mysql_xverify/constants.rb
@@ -149,8 +175,9 @@ files:
149
175
  homepage: https://github.com/winebarrel/active_record_mysql_xverify
150
176
  licenses:
151
177
  - MIT
152
- metadata: {}
153
- post_install_message:
178
+ metadata:
179
+ rubygems_mfa_required: 'true'
180
+ post_install_message:
154
181
  rdoc_options: []
155
182
  require_paths:
156
183
  - lib
@@ -158,15 +185,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
185
  requirements:
159
186
  - - ">="
160
187
  - !ruby/object:Gem::Version
161
- version: '0'
188
+ version: '2.7'
162
189
  required_rubygems_version: !ruby/object:Gem::Requirement
163
190
  requirements:
164
191
  - - ">="
165
192
  - !ruby/object:Gem::Version
166
193
  version: '0'
167
194
  requirements: []
168
- rubygems_version: 3.0.3
169
- signing_key:
195
+ rubygems_version: 3.3.7
196
+ signing_key:
170
197
  specification_version: 4
171
198
  summary: It is a library that performs extended verification when an error occurs
172
199
  when executing SQL.
data/.travis.yml DELETED
@@ -1,25 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.5.8
6
- - 2.6.6
7
- - 2.7.1
8
- env:
9
- - DATABASE_HOST=localhost DATABASE_USER=travis
10
- before_install:
11
- - for i in {1..60}; do mysqladmin -u travis ping && break; sleep 1; done
12
- script:
13
- - bundle exec rake
14
- gemfile:
15
- - gemfiles/ar42.gemfile
16
- - gemfiles/ar50.gemfile
17
- - gemfiles/ar51.gemfile
18
- - gemfiles/ar52.gemfile
19
- - gemfiles/ar60.gemfile
20
- services:
21
- - mysql
22
- jobs:
23
- exclude:
24
- - rvm: 2.7.1
25
- gemfile: gemfiles/ar42.gemfile
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.2.10"
6
- gem "mysql2", "< 0.5"
7
-
8
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.1.6"
6
-
7
- gemspec path: "../"