ar-multidb 0.6.0 → 0.8.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/.github/workflows/prs.yml +14 -14
- data/.gitignore +1 -1
- data/.rubocop.yml +5 -6
- data/CHANGELOG.md +10 -0
- data/ar-multidb.gemspec +10 -9
- data/gemfiles/{activerecord-5.1.gemfile → activerecord-7.1.gemfile} +1 -1
- data/gemfiles/{activerecord-5.2.gemfile → activerecord-7.2.gemfile} +1 -1
- data/gemfiles/{activerecord-6.0.gemfile → activerecord-8.0.gemfile} +1 -1
- data/lib/multidb/candidate.rb +2 -7
- data/lib/multidb/log_subscriber.rb +2 -2
- data/lib/multidb/version.rb +1 -1
- data/spec/lib/multidb/balancer_spec.rb +4 -4
- data/spec/lib/multidb/candidate_spec.rb +0 -10
- data/spec/lib/multidb/log_subscriber_extension_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +27 -39
- data/gemfiles/activerecord-6.1.gemfile +0 -7
- data/gemfiles/activerecord-7.0.gemfile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f198d581e4d1d0641b91ec64b79472987f90c8c69f717adc568caffbcaad148f
|
4
|
+
data.tar.gz: 33f6126cef8968a360f84fda234548687507f988beade03da58f092b8166cb13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba852c8001cb41bd738f2fae94268b5c37c9ebf5e549dcf326243dbfbff4c7c00a76641c2500dcfb96b37469543fc370a362cecec9c04134c031c0e40cc0fc90
|
7
|
+
data.tar.gz: 041f8e4d3fdb4559b764c4189a81801d60c96ad71f71a431970a62a06cd6e603b96bf20b223ff7032180a149329ffad76ed4da70090658d241909332255f13e2
|
data/.github/workflows/prs.yml
CHANGED
@@ -16,26 +16,26 @@ jobs:
|
|
16
16
|
fail-fast: false
|
17
17
|
matrix:
|
18
18
|
ruby:
|
19
|
-
- '2.5'
|
20
|
-
- '2.7'
|
21
19
|
- '3.0'
|
20
|
+
- '3.1'
|
21
|
+
- '3.2'
|
22
|
+
- '3.3'
|
23
|
+
- '3.4'
|
22
24
|
activerecord:
|
23
|
-
- '
|
24
|
-
- '
|
25
|
-
- '
|
26
|
-
- '6.1'
|
27
|
-
- '7.0'
|
25
|
+
- '7.1'
|
26
|
+
- '7.2'
|
27
|
+
- '8.0'
|
28
28
|
exclude:
|
29
|
-
- ruby: '2.5'
|
30
|
-
activerecord: '7.0'
|
31
29
|
- ruby: '3.0'
|
32
|
-
activerecord: '
|
30
|
+
activerecord: '7.2'
|
33
31
|
- ruby: '3.0'
|
34
|
-
activerecord: '
|
32
|
+
activerecord: '8.0'
|
33
|
+
- ruby: '3.1'
|
34
|
+
activerecord: '8.0'
|
35
35
|
env:
|
36
36
|
BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}.gemfile"
|
37
37
|
steps:
|
38
|
-
- uses: actions/checkout@
|
38
|
+
- uses: actions/checkout@v4
|
39
39
|
- name: Set up Ruby
|
40
40
|
uses: ruby/setup-ruby@v1
|
41
41
|
with:
|
@@ -49,7 +49,7 @@ jobs:
|
|
49
49
|
run: bundle exec rubocop
|
50
50
|
- name: Coveralls Parallel
|
51
51
|
if: "${{ !env.ACT }}"
|
52
|
-
uses: coverallsapp/github-action@
|
52
|
+
uses: coverallsapp/github-action@v2
|
53
53
|
with:
|
54
54
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
55
55
|
flag-name: run-${{ matrix.ruby }}-${{ matrix.activerecord }}
|
@@ -62,7 +62,7 @@ jobs:
|
|
62
62
|
steps:
|
63
63
|
- name: Coveralls Finished
|
64
64
|
if: "${{ !env.ACT }}"
|
65
|
-
uses: coverallsapp/github-action@
|
65
|
+
uses: coverallsapp/github-action@v2
|
66
66
|
with:
|
67
67
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
68
68
|
parallel-finished: true
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
|
1
|
+
plugins:
|
2
2
|
- rubocop-rspec
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
TargetRubyVersion:
|
5
|
+
TargetRubyVersion: 3.0
|
6
6
|
SuggestExtensions: false
|
7
7
|
NewCops: disable
|
8
8
|
Exclude:
|
9
9
|
- '**/vendor/**/*'
|
10
10
|
|
11
|
-
Gemspec/
|
11
|
+
Gemspec/DeprecatedAttributeAssignment: # new in 1.30
|
12
12
|
Enabled: true
|
13
13
|
Gemspec/RequireMFA: # new in 1.23
|
14
14
|
Enabled: true
|
@@ -27,9 +27,6 @@ Layout/SpaceBeforeBrackets: # new in 1.7
|
|
27
27
|
|
28
28
|
Lint/AmbiguousAssignment: # new in 1.7
|
29
29
|
Enabled: true
|
30
|
-
Lint/AmbiguousBlockAssociation:
|
31
|
-
IgnoredMethods:
|
32
|
-
- change
|
33
30
|
Lint/AmbiguousOperatorPrecedence: # new in 1.21
|
34
31
|
Enabled: true
|
35
32
|
Lint/AmbiguousRange: # new in 1.19
|
@@ -110,6 +107,8 @@ RSpec/MultipleExpectations:
|
|
110
107
|
Enabled: false
|
111
108
|
RSpec/NestedGroups:
|
112
109
|
Max: 4
|
110
|
+
RSpec/VerifiedDoubleReference: # new in 2.10
|
111
|
+
Enabled: false
|
113
112
|
|
114
113
|
Security/CompoundHash: # new in 1.28
|
115
114
|
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
|
6
6
|
|
7
|
+
## [0.8.0]
|
8
|
+
### Changed
|
9
|
+
- dropped support for Ruby < 3.0
|
10
|
+
- dropped support for AR < 7.1
|
11
|
+
- add support for Rails 7.2 and 8.0
|
12
|
+
|
13
|
+
## [0.7.0]
|
14
|
+
### Changed
|
15
|
+
- add AR 7.1 support
|
16
|
+
|
7
17
|
## [0.6.0]
|
8
18
|
### Changed
|
9
19
|
- dropped ruby 2.4 support
|
data/ar-multidb.gemspec
CHANGED
@@ -8,26 +8,27 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.version = Multidb::VERSION
|
9
9
|
s.authors = ['Alexander Staubo', 'Edward Rudd']
|
10
10
|
s.email = %w[alex@bengler.no urkle@outoforder.cc]
|
11
|
-
s.homepage = ''
|
11
|
+
s.homepage = 'https://github.com/OutOfOrder/multidb'
|
12
12
|
s.summary = s.description = 'Multidb is an ActiveRecord extension for switching between multiple database connections, such as primary/replica setups.'
|
13
13
|
s.license = 'MIT'
|
14
14
|
s.metadata['rubygems_mfa_required'] = 'true'
|
15
|
+
s.metadata['changelog_uri'] = 'https://github.com/OutOfOrder/multidb/blob/master/CHANGELOG.md'
|
16
|
+
s.metadata['source_code_uri'] = 'https://github.com/OutOfOrder/multidb'
|
15
17
|
|
16
18
|
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
19
20
|
s.require_paths = ['lib']
|
20
21
|
|
21
|
-
s.required_ruby_version = '>=
|
22
|
+
s.required_ruby_version = '>= 3.0.0'
|
22
23
|
|
23
|
-
s.add_runtime_dependency 'activerecord', '>=
|
24
|
-
s.add_runtime_dependency 'activesupport', '>=
|
24
|
+
s.add_runtime_dependency 'activerecord', '>= 7.1', '< 8.1'
|
25
|
+
s.add_runtime_dependency 'activesupport', '>= 7.1', '< 8.1'
|
25
26
|
|
26
27
|
s.add_development_dependency 'rake', '~> 13.0'
|
27
28
|
s.add_development_dependency 'rspec', '~> 3.8'
|
28
|
-
s.add_development_dependency 'rubocop', '~> 1.
|
29
|
-
s.add_development_dependency 'rubocop-rspec', '~>
|
30
|
-
s.add_development_dependency 'simplecov', '~> 0.
|
29
|
+
s.add_development_dependency 'rubocop', '~> 1.75.0'
|
30
|
+
s.add_development_dependency 'rubocop-rspec', '~> 3.6.0'
|
31
|
+
s.add_development_dependency 'simplecov', '~> 0.22.0'
|
31
32
|
s.add_development_dependency 'simplecov-lcov', '~> 0.8.0'
|
32
|
-
s.add_development_dependency 'sqlite3', '~>
|
33
|
+
s.add_development_dependency 'sqlite3', '~> 2'
|
33
34
|
end
|
data/lib/multidb/candidate.rb
CHANGED
@@ -2,19 +2,14 @@
|
|
2
2
|
|
3
3
|
module Multidb
|
4
4
|
class Candidate
|
5
|
-
|
6
|
-
SPEC_NAME = if USE_RAILS_61
|
7
|
-
'ActiveRecord::Base'
|
8
|
-
else
|
9
|
-
'primary'
|
10
|
-
end
|
5
|
+
SPEC_NAME = 'ActiveRecord::Base'
|
11
6
|
|
12
7
|
def initialize(name, target)
|
13
8
|
@name = name
|
14
9
|
|
15
10
|
case target
|
16
11
|
when Hash
|
17
|
-
target = target.merge(name: 'primary')
|
12
|
+
target = target.merge(name: 'primary')
|
18
13
|
|
19
14
|
@connection_handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
|
20
15
|
@connection_handler.establish_connection(target)
|
@@ -8,11 +8,11 @@ module Multidb
|
|
8
8
|
super
|
9
9
|
end
|
10
10
|
|
11
|
-
def debug(msg)
|
11
|
+
def debug(msg = nil)
|
12
12
|
name = Multidb.balancer.current_connection_name
|
13
13
|
if name
|
14
14
|
db = color("[DB: #{name}]", ActiveSupport::LogSubscriber::GREEN, true)
|
15
|
-
super(db + msg)
|
15
|
+
super(db + msg.to_s)
|
16
16
|
else
|
17
17
|
super
|
18
18
|
end
|
data/lib/multidb/version.rb
CHANGED
@@ -36,7 +36,7 @@ RSpec.describe Multidb::Balancer do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'sets fallback to false' do
|
39
|
-
expect(subject.fallback).to
|
39
|
+
expect(subject.fallback).to be(false)
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'when rails ENV is development' do
|
@@ -45,7 +45,7 @@ RSpec.describe Multidb::Balancer do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'sets fallback to true' do
|
48
|
-
expect(subject.fallback).to
|
48
|
+
expect(subject.fallback).to be(true)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -55,7 +55,7 @@ RSpec.describe Multidb::Balancer do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'sets fallback to true' do
|
58
|
-
expect(subject.fallback).to
|
58
|
+
expect(subject.fallback).to be(true)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -78,7 +78,7 @@ RSpec.describe Multidb::Balancer do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'sets fallback to true' do
|
81
|
-
expect(subject.fallback).to
|
81
|
+
expect(subject.fallback).to be(true)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -17,16 +17,6 @@ RSpec.describe Multidb::Candidate do
|
|
17
17
|
handler = subject.instance_variable_get(:@connection_handler)
|
18
18
|
expect(handler).to an_instance_of(ActiveRecord::ConnectionAdapters::ConnectionHandler)
|
19
19
|
end
|
20
|
-
|
21
|
-
it 'merges the name: primary into the hash', rails: '< 6.1' do
|
22
|
-
handler = instance_double('ActiveRecord::ConnectionAdapters::ConnectionHandler')
|
23
|
-
allow(ActiveRecord::ConnectionAdapters::ConnectionHandler).to receive(:new).and_return(handler)
|
24
|
-
allow(handler).to receive(:establish_connection)
|
25
|
-
|
26
|
-
subject
|
27
|
-
|
28
|
-
expect(handler).to have_received(:establish_connection).with(hash_including(name: 'primary'))
|
29
|
-
end
|
30
20
|
end
|
31
21
|
|
32
22
|
context 'when target is a connection handler' do
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,7 @@ require 'fileutils'
|
|
13
13
|
$LOAD_PATH.unshift(File.expand_path('lib', __dir__))
|
14
14
|
require 'multidb'
|
15
15
|
|
16
|
-
Dir[File.join(__dir__, 'support', '**', '*.rb')].
|
16
|
+
Dir[File.join(__dir__, 'support', '**', '*.rb')].each { |f| require f }
|
17
17
|
|
18
18
|
RSpec.configure do |config|
|
19
19
|
config.disable_monkey_patching!
|
@@ -39,7 +39,7 @@ RSpec.configure do |config|
|
|
39
39
|
end
|
40
40
|
|
41
41
|
config.before do
|
42
|
-
ActiveRecord::Base.clear_all_connections!
|
42
|
+
ActiveRecord::Base.connection_handler.clear_all_connections!
|
43
43
|
Multidb.reset!
|
44
44
|
end
|
45
45
|
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar-multidb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Staubo
|
8
8
|
- Edward Rudd
|
9
|
-
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activerecord
|
@@ -17,40 +16,40 @@ dependencies:
|
|
17
16
|
requirements:
|
18
17
|
- - ">="
|
19
18
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
19
|
+
version: '7.1'
|
21
20
|
- - "<"
|
22
21
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
22
|
+
version: '8.1'
|
24
23
|
type: :runtime
|
25
24
|
prerelease: false
|
26
25
|
version_requirements: !ruby/object:Gem::Requirement
|
27
26
|
requirements:
|
28
27
|
- - ">="
|
29
28
|
- !ruby/object:Gem::Version
|
30
|
-
version: '
|
29
|
+
version: '7.1'
|
31
30
|
- - "<"
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
32
|
+
version: '8.1'
|
34
33
|
- !ruby/object:Gem::Dependency
|
35
34
|
name: activesupport
|
36
35
|
requirement: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
39
|
+
version: '7.1'
|
41
40
|
- - "<"
|
42
41
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
42
|
+
version: '8.1'
|
44
43
|
type: :runtime
|
45
44
|
prerelease: false
|
46
45
|
version_requirements: !ruby/object:Gem::Requirement
|
47
46
|
requirements:
|
48
47
|
- - ">="
|
49
48
|
- !ruby/object:Gem::Version
|
50
|
-
version: '
|
49
|
+
version: '7.1'
|
51
50
|
- - "<"
|
52
51
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
52
|
+
version: '8.1'
|
54
53
|
- !ruby/object:Gem::Dependency
|
55
54
|
name: rake
|
56
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,42 +84,42 @@ dependencies:
|
|
85
84
|
requirements:
|
86
85
|
- - "~>"
|
87
86
|
- !ruby/object:Gem::Version
|
88
|
-
version: 1.
|
87
|
+
version: 1.75.0
|
89
88
|
type: :development
|
90
89
|
prerelease: false
|
91
90
|
version_requirements: !ruby/object:Gem::Requirement
|
92
91
|
requirements:
|
93
92
|
- - "~>"
|
94
93
|
- !ruby/object:Gem::Version
|
95
|
-
version: 1.
|
94
|
+
version: 1.75.0
|
96
95
|
- !ruby/object:Gem::Dependency
|
97
96
|
name: rubocop-rspec
|
98
97
|
requirement: !ruby/object:Gem::Requirement
|
99
98
|
requirements:
|
100
99
|
- - "~>"
|
101
100
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
101
|
+
version: 3.6.0
|
103
102
|
type: :development
|
104
103
|
prerelease: false
|
105
104
|
version_requirements: !ruby/object:Gem::Requirement
|
106
105
|
requirements:
|
107
106
|
- - "~>"
|
108
107
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
108
|
+
version: 3.6.0
|
110
109
|
- !ruby/object:Gem::Dependency
|
111
110
|
name: simplecov
|
112
111
|
requirement: !ruby/object:Gem::Requirement
|
113
112
|
requirements:
|
114
113
|
- - "~>"
|
115
114
|
- !ruby/object:Gem::Version
|
116
|
-
version: 0.
|
115
|
+
version: 0.22.0
|
117
116
|
type: :development
|
118
117
|
prerelease: false
|
119
118
|
version_requirements: !ruby/object:Gem::Requirement
|
120
119
|
requirements:
|
121
120
|
- - "~>"
|
122
121
|
- !ruby/object:Gem::Version
|
123
|
-
version: 0.
|
122
|
+
version: 0.22.0
|
124
123
|
- !ruby/object:Gem::Dependency
|
125
124
|
name: simplecov-lcov
|
126
125
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,14 +140,14 @@ dependencies:
|
|
141
140
|
requirements:
|
142
141
|
- - "~>"
|
143
142
|
- !ruby/object:Gem::Version
|
144
|
-
version: '
|
143
|
+
version: '2'
|
145
144
|
type: :development
|
146
145
|
prerelease: false
|
147
146
|
version_requirements: !ruby/object:Gem::Requirement
|
148
147
|
requirements:
|
149
148
|
- - "~>"
|
150
149
|
- !ruby/object:Gem::Version
|
151
|
-
version: '
|
150
|
+
version: '2'
|
152
151
|
description: Multidb is an ActiveRecord extension for switching between multiple database
|
153
152
|
connections, such as primary/replica setups.
|
154
153
|
email:
|
@@ -168,11 +167,9 @@ files:
|
|
168
167
|
- README.markdown
|
169
168
|
- Rakefile
|
170
169
|
- ar-multidb.gemspec
|
171
|
-
- gemfiles/activerecord-
|
172
|
-
- gemfiles/activerecord-
|
173
|
-
- gemfiles/activerecord-
|
174
|
-
- gemfiles/activerecord-6.1.gemfile
|
175
|
-
- gemfiles/activerecord-7.0.gemfile
|
170
|
+
- gemfiles/activerecord-7.1.gemfile
|
171
|
+
- gemfiles/activerecord-7.2.gemfile
|
172
|
+
- gemfiles/activerecord-8.0.gemfile
|
176
173
|
- lib/ar-multidb.rb
|
177
174
|
- lib/multidb.rb
|
178
175
|
- lib/multidb/balancer.rb
|
@@ -190,12 +187,13 @@ files:
|
|
190
187
|
- spec/spec_helper.rb
|
191
188
|
- spec/support/have_database_matcher.rb
|
192
189
|
- spec/support/helpers.rb
|
193
|
-
homepage:
|
190
|
+
homepage: https://github.com/OutOfOrder/multidb
|
194
191
|
licenses:
|
195
192
|
- MIT
|
196
193
|
metadata:
|
197
194
|
rubygems_mfa_required: 'true'
|
198
|
-
|
195
|
+
changelog_uri: https://github.com/OutOfOrder/multidb/blob/master/CHANGELOG.md
|
196
|
+
source_code_uri: https://github.com/OutOfOrder/multidb
|
199
197
|
rdoc_options: []
|
200
198
|
require_paths:
|
201
199
|
- lib
|
@@ -203,25 +201,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
203
201
|
requirements:
|
204
202
|
- - ">="
|
205
203
|
- !ruby/object:Gem::Version
|
206
|
-
version:
|
204
|
+
version: 3.0.0
|
207
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
206
|
requirements:
|
209
207
|
- - ">="
|
210
208
|
- !ruby/object:Gem::Version
|
211
209
|
version: '0'
|
212
210
|
requirements: []
|
213
|
-
rubygems_version: 3.
|
214
|
-
signing_key:
|
211
|
+
rubygems_version: 3.6.7
|
215
212
|
specification_version: 4
|
216
213
|
summary: Multidb is an ActiveRecord extension for switching between multiple database
|
217
214
|
connections, such as primary/replica setups.
|
218
|
-
test_files:
|
219
|
-
- spec/lib/multidb/balancer_spec.rb
|
220
|
-
- spec/lib/multidb/candidate_spec.rb
|
221
|
-
- spec/lib/multidb/configuration_spec.rb
|
222
|
-
- spec/lib/multidb/log_subscriber_extension_spec.rb
|
223
|
-
- spec/lib/multidb/model_extensions_spec.rb
|
224
|
-
- spec/lib/multidb_spec.rb
|
225
|
-
- spec/spec_helper.rb
|
226
|
-
- spec/support/have_database_matcher.rb
|
227
|
-
- spec/support/helpers.rb
|
215
|
+
test_files: []
|