active_record_mysql_xverify 0.2.2 → 0.4.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: f7575ed4ef4e91aa458e8f7f9a4fb38319b7fcdc07e89a6fe101c4998dbc1a8b
4
+ data.tar.gz: 3b88c54bffb73d7d69ca5df81172b72a3df4f4cd03e568967a1969133e6f17bb
5
5
  SHA512:
6
- metadata.gz: d480ed34d3c86dc5f62d082e86161c63b1478e8d8dbb185c25de527b48d8644d9eb6a9e56e94fc7525ee9700c28e156788811256e1e1f05b68dbfb8bdc9a912a
7
- data.tar.gz: 2106e3d52403afc79bad9a27b0cecc0f2c174cc4f454d674393258288f6b3d370e215309b27b0cac6c39bbf7bb19c0deedcfc55a14be147a5e15abc846feab62
6
+ metadata.gz: 956a695d38ac8f6c5d73c2b7e297c6f1a1615f57176b3b33d8c1a9d3dee08e5c1aa5343b35d8d8e3a6f22a3e98b75b5f9699734d6ddcc8a97893a32fcbb3b77c
7
+ data.tar.gz: 152451692be0cb60f5307981fb12dc4535de405d914e511692c93f13becd9187ce68cb2d99de26a6da24f7d0ffe6bb2866107345ffbec56e8dd32bcd78b0299c
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "weekly"
@@ -0,0 +1,45 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ concurrency:
8
+ group: ${{ github.workflow }}-${{ github.ref }}
9
+ cancel-in-progress: true
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+ services:
15
+ mysql:
16
+ image: mysql:5.7
17
+ ports:
18
+ - 3306:3306
19
+ env:
20
+ MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
21
+ options: --health-cmd "mysqladmin ping -h localhost" --health-interval 1s --health-timeout 3s --health-retries 60
22
+ strategy:
23
+ fail-fast: false
24
+ matrix:
25
+ ruby:
26
+ - 2.7
27
+ - 3.0
28
+ - 3.1
29
+ - 3.2
30
+ gemfile:
31
+ - gemfiles/ar60.gemfile
32
+ - gemfiles/ar61.gemfile
33
+ - gemfiles/ar70.gemfile
34
+ - gemfiles/ar71.gemfile
35
+ env:
36
+ DATABASE_HOST: 127.0.0.1
37
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+ - uses: ruby/setup-ruby@v1
41
+ with:
42
+ ruby-version: ${{ matrix.ruby }}
43
+ bundler-cache: true
44
+ - run: bundle install
45
+ - run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,10 +1,13 @@
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
- Metrics/LineLength:
10
+ Layout/LineLength:
8
11
  Enabled: false
9
12
  Metrics/MethodLength:
10
13
  Enabled: false
@@ -14,80 +17,9 @@ Style/Documentation:
14
17
  Enabled: false
15
18
  Style/TrailingCommaInHashLiteral:
16
19
  EnforcedStyleForMultiline: consistent_comma
17
- Gemspec/RequiredRubyVersion:
20
+ Gemspec/DevelopmentDependencies:
21
+ Enabled: false
22
+ Metrics/CyclomaticComplexity:
23
+ Enabled: false
24
+ Metrics/PerceivedComplexity:
18
25
  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,17 @@
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'
3
+ appraise 'ar60' do
4
+ gem 'activerecord', '~> 6.0.3'
10
5
  end
11
6
 
12
- appraise 'ar51' do
13
- gem 'activerecord', '~> 5.1.6'
7
+ appraise 'ar61' do
8
+ gem 'activerecord', '~> 6.1.0'
14
9
  end
15
10
 
16
- appraise 'ar52' do
17
- gem 'activerecord', '~> 5.2.1'
11
+ appraise 'ar70' do
12
+ gem 'activerecord', '~> 7.0.0'
18
13
  end
19
14
 
20
- appraise 'ar60' do
21
- gem 'activerecord', '~> 6.0.3'
15
+ appraise 'ar71' do
16
+ gem 'activerecord', '~> 7.1.0'
22
17
  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,4 @@ RUN apt-get update && \
6
6
  libmysqlclient-dev \
7
7
  rubygems
8
8
 
9
- COPY ./ /mnt/
10
9
  WORKDIR /mnt
11
- RUN gem update bundler -f && \
12
- bundle install && \
13
- 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,20 @@ Completed 302 Found in 150ms (ActiveRecord: 145.2ms)
132
134
 
133
135
  ## Test
134
136
 
135
- ## Test
137
+ ### Preparation
138
+
139
+ ```sh
140
+ docker compose build client
141
+ docker compose run --rm client gem update bundler
142
+ docker compose run --rm client bundle install
143
+ docker compose run --rm client appraisal install
144
+ ```
145
+
146
+ ### Run tests
136
147
 
137
148
  ```sh
138
- docker-compose build
139
- docker-compose run client bundle exec appraisal ar60 rake
149
+ docker compose up -d
150
+ docker compose run client appraisal ar60 rake
140
151
  ```
141
152
 
142
153
  ## 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,12 +1,17 @@
1
- version: "3.8"
2
1
  services:
3
2
  client:
4
3
  build: .
5
4
  volumes:
6
5
  - ./:/mnt
7
- depends_on:
8
- - mysql
6
+ - gems_bin:/usr/local/bin
7
+ - gems:/usr/local/lib/ruby/gems/2.7.0
8
+ profiles:
9
+ - extra
9
10
  mysql:
11
+ platform: linux/amd64
10
12
  image: mysql:5.7
11
13
  environment:
12
14
  MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
15
+ volumes:
16
+ gems_bin:
17
+ gems:
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.0.7"
5
+ gem "activerecord", "~> 6.1.0"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.1.6"
5
+ gem "activerecord", "~> 7.0.0"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.2.1"
5
+ gem "activerecord", "~> 7.1.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}"
@@ -3,20 +3,20 @@
3
3
  module ActiveRecordMysqlXverify
4
4
  module Verifier
5
5
  def active?
6
- if _extend_verify?
6
+ if (@raw_connection || @connection) && _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(@raw_connection || @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(
19
- "Invalid connection: #{ActiveRecordMysqlXverify::Utils.mysql2_connection_info(@connection)}"
19
+ "Invalid connection: #{ActiveRecordMysqlXverify::Utils.mysql2_connection_info(@raw_connection || @connection)}"
20
20
  )
21
21
  end
22
22
 
@@ -27,7 +27,7 @@ module ActiveRecordMysqlXverify
27
27
  end
28
28
 
29
29
  def _build_verify_error_message(e)
30
- "cause: #{e.message} [#{e.class}, " + ActiveRecordMysqlXverify::Utils.mysql2_connection_info(@connection)
30
+ "cause: #{e.message} [#{e.class}, " + ActiveRecordMysqlXverify::Utils.mysql2_connection_info(@raw_connection || @connection)
31
31
  end
32
32
 
33
33
  def _extend_verify?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordMysqlXverify
4
- VERSION = '0.2.2'
4
+ VERSION = '0.4.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.4.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-10-09 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,11 @@ executables: []
116
144
  extensions: []
117
145
  extra_rdoc_files: []
118
146
  files:
147
+ - ".github/dependabot.yml"
148
+ - ".github/workflows/test.yml"
119
149
  - ".gitignore"
120
150
  - ".rspec"
121
151
  - ".rubocop.yml"
122
- - ".travis.yml"
123
152
  - Appraisals
124
153
  - Dockerfile
125
154
  - Gemfile
@@ -127,15 +156,12 @@ files:
127
156
  - README.md
128
157
  - Rakefile
129
158
  - activerecord_mysql_xverify.gemspec
130
- - bin/console
131
- - bin/setup
132
159
  - docker-compose.yml
133
160
  - gemfiles/.bundle/config
134
- - gemfiles/ar42.gemfile
135
- - gemfiles/ar50.gemfile
136
- - gemfiles/ar51.gemfile
137
- - gemfiles/ar52.gemfile
138
161
  - gemfiles/ar60.gemfile
162
+ - gemfiles/ar61.gemfile
163
+ - gemfiles/ar70.gemfile
164
+ - gemfiles/ar71.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
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'active_record_mysql_xverify'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require 'irb'
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -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: "../"