fresh_connection 3.1.0 → 3.1.1.rc1

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
  SHA256:
3
- metadata.gz: d21ad20eb5180bd0bfd7c7e4ec352328e73f4be954215aa49ea7056442738490
4
- data.tar.gz: 0f7acb28bd1c0fb738491036aa617e43ea0d994fef71d7151d0b977bbd9a28e8
3
+ metadata.gz: ba2f6c91d19fa7619609c82c464bdd7d11eb9fcc6322fd02a02e5e5b542d1463
4
+ data.tar.gz: 5861ad563a66ffd18f5050ff7f1852541cd8e5e8a2c2954f8015443a55f9e454
5
5
  SHA512:
6
- metadata.gz: 70d6f0fbb318ac1687e2ac2fe915c213fd25403f2938aa43037c0aa9bc618a29eaeb0806638390778b364ab7b8dde3488bd5f380cd31fd3ce68a04005793ddd8
7
- data.tar.gz: 820751f83fb8f143c700ad6073a72ee2d7427a9e907984c7afe7ed970d90bee40d913550c5f95ce3baff6e1fc3efd3388d6ff93d49039fda7ff206cc0fa84f1c
6
+ metadata.gz: d930efef155cbe217b93256cf5f78b54d30f19d41a23ef4daefda3d65acb3c5364479a5dd0cf3454aefc6c1d7105c91ec7b6a4b75419d3a0faf3e6e3f36e3e69
7
+ data.tar.gz: bed2bf124336ef4d4d1e979bd9bb2df5aa39ea263b2525f46e07edd79e6cc7cc75140db0d487e2da90cabf16fa257d26e780a77c2f3d89b703279a88d55eb740
data/.travis.yml CHANGED
@@ -6,12 +6,13 @@ before_install:
6
6
  - gem update --system
7
7
  - gem --version
8
8
  rvm:
9
- - 2.5.8
10
- - 2.6.6
11
- - 2.7.1
9
+ - 2.6.8
10
+ - 2.7.4
11
+ - 3.0.2
12
12
  gemfile:
13
13
  - gemfiles/rails52.gemfile
14
14
  - gemfiles/rails60.gemfile
15
+ - gemfiles/rails61.gemfile
15
16
  script:
16
17
  - "bin/test"
17
18
  matrix:
data/Appraisals CHANGED
@@ -6,3 +6,7 @@ end
6
6
  appraise "rails60" do
7
7
  gem 'activerecord', '~> 6.0.0'
8
8
  end
9
+
10
+ appraise "rails61" do
11
+ gem 'activerecord', '~> 6.1.0'
12
+ end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency 'activerecord', '>= 5.2.0', '< 6.1'
22
+ spec.add_dependency 'activerecord', '>= 5.2.0', '< 7.0'
23
23
 
24
24
  spec.add_development_dependency 'mysql2', '>= 0.4.4'
25
25
  spec.add_development_dependency 'pg', '>= 0.18', '< 2.0'
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 6.1.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FreshConnection
4
+ class ConnectionSpecification
5
+ module Rails60
6
+ def spec
7
+ ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(config_with_spec_name).spec(@spec_name.to_sym)
8
+ end
9
+
10
+ private
11
+
12
+ def config_with_spec_name
13
+ if defined?(ActiveRecord::DatabaseConfigurations)
14
+ ActiveRecord::DatabaseConfigurations.new(@spec_name => build_config)
15
+ else
16
+ { @spec_name => build_config }
17
+ end
18
+ end
19
+
20
+ def config_from_url
21
+ ActiveRecord::ConnectionAdapters::ConnectionSpecification::ConnectionUrlResolver.new(database_group_url).to_hash
22
+ end
23
+
24
+ def base_config
25
+ ActiveRecord::Base.connection_pool.spec.config
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FreshConnection
4
+ class ConnectionSpecification
5
+ module Rails61
6
+ def spec
7
+ db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(@spec_name.to_sym, ActiveRecord::Base.connection_pool.db_config.name, build_config)
8
+ ActiveRecord::ConnectionAdapters::PoolConfig.new(ActiveRecord::Base, db_config)
9
+ end
10
+
11
+ private
12
+
13
+ def config_from_url
14
+ ActiveRecord::DatabaseConfigurations::ConnectionUrlResolver.new(database_group_url).to_hash
15
+ end
16
+
17
+ def base_config
18
+ ActiveRecord::Base.connection_pool.db_config.configuration_hash
19
+ end
20
+ end
21
+ end
22
+ end
@@ -9,16 +9,8 @@ module FreshConnection
9
9
  @modify_spec = modify_spec.with_indifferent_access if modify_spec
10
10
  end
11
11
 
12
- def spec
13
- resolver.spec(@spec_name.to_sym)
14
- end
15
-
16
12
  private
17
13
 
18
- def resolver
19
- ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(build_config)
20
- end
21
-
22
14
  def build_config
23
15
  config = base_config.with_indifferent_access
24
16
 
@@ -27,11 +19,7 @@ module FreshConnection
27
19
 
28
20
  config = config.merge(@modify_spec) if defined?(@modify_spec)
29
21
 
30
- if defined?(ActiveRecord::DatabaseConfigurations)
31
- ActiveRecord::DatabaseConfigurations.new(@spec_name => config)
32
- else
33
- { @spec_name => config }
34
- end
22
+ config
35
23
  end
36
24
 
37
25
  def replica_config(config)
@@ -42,14 +30,6 @@ module FreshConnection
42
30
  end
43
31
  end
44
32
 
45
- def config_from_url
46
- ActiveRecord::ConnectionAdapters::ConnectionSpecification::ConnectionUrlResolver.new(database_group_url).to_hash
47
- end
48
-
49
- def base_config
50
- ActiveRecord::Base.connection_pool.spec.config
51
- end
52
-
53
33
  def database_group_url
54
34
  ENV["DATABASE_#{@spec_name.upcase}_URL"]
55
35
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FreshConnection
4
+ module Extend
5
+ module ArConnectionHandler
6
+ private def resolve_pool_config(*args)
7
+ pool_config = super
8
+
9
+ case pool_config.db_config.adapter.to_s
10
+ when "mysql", "mysql2"
11
+ require 'fresh_connection/extend/adapters/m2_adapter'
12
+ __extend_adapter_by_fc(::ActiveRecord::ConnectionAdapters::Mysql2Adapter, M2Adapter)
13
+ when "postgresql"
14
+ require 'fresh_connection/extend/adapters/pg_adapter'
15
+ __extend_adapter_by_fc(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter, PgAdapter)
16
+ else
17
+ raise NotImplementedError, "This adapter('#{pool_config.db_config.adapter}') is not supported. If you specified the mysql or postgres adapter, it's probably a bug in FreshConnection. Please teach me (https://github.com/tsukasaoishi/fresh_connection/issues/new)"
18
+ end
19
+
20
+ pool_config
21
+ end
22
+
23
+ def __extend_adapter_by_fc(klass, extend_adapter)
24
+ return if klass.include?(extend_adapter)
25
+ klass.prepend BaseAdapter
26
+ klass.prepend extend_adapter
27
+ end
28
+ end
29
+ end
30
+ end
@@ -10,13 +10,31 @@ ActiveSupport.on_load(:active_record) do
10
10
  require 'fresh_connection/extend/ar_relation'
11
11
  require 'fresh_connection/extend/ar_relation_merger'
12
12
  require 'fresh_connection/extend/ar_statement_cache'
13
- require 'fresh_connection/extend/ar_resolver'
14
13
 
15
14
  ActiveRecord::Base.extend FreshConnection::Extend::ArBase
16
15
  ActiveRecord::Relation.prepend FreshConnection::Extend::ArRelation
17
16
  ActiveRecord::Relation::Merger.prepend FreshConnection::Extend::ArRelationMerger
18
17
  ActiveRecord::StatementCache.prepend FreshConnection::Extend::ArStatementCache
19
- ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.prepend(
20
- FreshConnection::Extend::ArResolver
21
- )
18
+
19
+ if ActiveRecord::VERSION::MAJOR == 6 && ActiveRecord::VERSION::MINOR == 1
20
+ require 'fresh_connection/extend/ar_connection_handler'
21
+ ActiveRecord::ConnectionAdapters::ConnectionHandler.prepend(
22
+ FreshConnection::Extend::ArConnectionHandler
23
+ )
24
+
25
+ require 'fresh_connection/connection_specification/rails_61'
26
+ FreshConnection::ConnectionSpecification.include(
27
+ FreshConnection::ConnectionSpecification::Rails61
28
+ )
29
+ else
30
+ require 'fresh_connection/extend/ar_resolver'
31
+ ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.prepend(
32
+ FreshConnection::Extend::ArResolver
33
+ )
34
+
35
+ require 'fresh_connection/connection_specification/rails_60'
36
+ FreshConnection::ConnectionSpecification.include(
37
+ FreshConnection::ConnectionSpecification::Rails60
38
+ )
39
+ end
22
40
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FreshConnection
4
- VERSION = "3.1.0"
4
+ VERSION = "3.1.1.rc1"
5
5
  end
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fresh_connection
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsukasa OISHI
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-02 00:00:00.000000000 Z
11
+ date: 2021-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 5.2.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.1'
22
+ version: '7.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 5.2.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.1'
32
+ version: '7.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: mysql2
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -156,17 +156,21 @@ files:
156
156
  - fresh_connection.gemspec
157
157
  - gemfiles/rails52.gemfile
158
158
  - gemfiles/rails60.gemfile
159
+ - gemfiles/rails61.gemfile
159
160
  - lib/fresh_connection.rb
160
161
  - lib/fresh_connection/abstract_connection_manager.rb
161
162
  - lib/fresh_connection/access_control.rb
162
163
  - lib/fresh_connection/connection_manager.rb
163
164
  - lib/fresh_connection/connection_specification.rb
165
+ - lib/fresh_connection/connection_specification/rails_60.rb
166
+ - lib/fresh_connection/connection_specification/rails_61.rb
164
167
  - lib/fresh_connection/executor_hook.rb
165
168
  - lib/fresh_connection/extend.rb
166
169
  - lib/fresh_connection/extend/adapters/base_adapter.rb
167
170
  - lib/fresh_connection/extend/adapters/m2_adapter.rb
168
171
  - lib/fresh_connection/extend/adapters/pg_adapter.rb
169
172
  - lib/fresh_connection/extend/ar_base.rb
173
+ - lib/fresh_connection/extend/ar_connection_handler.rb
170
174
  - lib/fresh_connection/extend/ar_relation.rb
171
175
  - lib/fresh_connection/extend/ar_relation_merger.rb
172
176
  - lib/fresh_connection/extend/ar_resolver.rb
@@ -190,11 +194,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
194
  version: '0'
191
195
  required_rubygems_version: !ruby/object:Gem::Requirement
192
196
  requirements:
193
- - - ">="
197
+ - - ">"
194
198
  - !ruby/object:Gem::Version
195
- version: '0'
199
+ version: 1.3.1
196
200
  requirements: []
197
- rubygems_version: 3.1.2
201
+ rubygems_version: 3.1.4
198
202
  signing_key:
199
203
  specification_version: 4
200
204
  summary: FreshConnection supports connections with configured replica servers.