active_record_proxy_adapters 0.9.1 → 0.10.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/lib/active_record_proxy_adapters/active_record_context.rb +1 -1
- data/lib/active_record_proxy_adapters/connection_handling/mysql2_proxy.rb +0 -37
- data/lib/active_record_proxy_adapters/connection_handling/postgresql_proxy.rb +0 -38
- data/lib/active_record_proxy_adapters/connection_handling/sqlite3_proxy.rb +0 -20
- data/lib/active_record_proxy_adapters/connection_handling/trilogy_proxy.rb +0 -36
- data/lib/active_record_proxy_adapters/primary_replica_proxy.rb +2 -4
- data/lib/active_record_proxy_adapters/version.rb +1 -1
- metadata +9 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bca625e0a728907c505db941a4398b5aa144dcdd5f6866ac9a3969f0b783c4d0
|
|
4
|
+
data.tar.gz: 3ab824330a83e8309b31763b24fe7c74ba0efff2a1eff28505d2a8216442f557
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1bc0567abfff9e1877abe107074a7e3f35f574ecefc2584f188809a0940c37a9192c88f3ae71f0e682d7115de75cd8b82ef827874e75195dc635572a8a8c7173
|
|
7
|
+
data.tar.gz: 6ee734e3da7c41d458403e10589d3edd8126862ddcfa2d63034d75c884ec98e383c58e0877166c25155c44ef3a2c13e307378df850b47b0da77d103ff31d57c2
|
|
@@ -22,7 +22,7 @@ module ActiveRecordProxyAdapters
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def active_record_v7?
|
|
25
|
-
active_record_version >= Gem::Version.new("7.
|
|
25
|
+
active_record_version >= Gem::Version.new("7.2") && active_record_version < Gem::Version.new("8.0")
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def active_record_v7_2_or_greater?
|
|
@@ -6,40 +6,3 @@ rescue LoadError
|
|
|
6
6
|
# mysql2 not available
|
|
7
7
|
return
|
|
8
8
|
end
|
|
9
|
-
|
|
10
|
-
module ActiveRecordProxyAdapters
|
|
11
|
-
module Mysql2
|
|
12
|
-
# Module to extend ActiveRecord::Base with the connection handling methods.
|
|
13
|
-
# Required to make adapter work in ActiveRecord versions <= 7.2.x
|
|
14
|
-
module ConnectionHandling
|
|
15
|
-
def mysql2_proxy_adapter_class
|
|
16
|
-
::ActiveRecord::ConnectionAdapters::Mysql2ProxyAdapter
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# This method is a copy and paste from Rails' mysql2_connection,
|
|
20
|
-
# replacing Mysql2Adapter by Mysql2ProxyAdapter
|
|
21
|
-
# This is required by ActiveRecord versions <= 7.2.x to establish a connection using the adapter.
|
|
22
|
-
def mysql2_proxy_connection(config) # rubocop:disable Metrics/MethodLength
|
|
23
|
-
config = config.symbolize_keys
|
|
24
|
-
config[:flags] ||= 0
|
|
25
|
-
|
|
26
|
-
if config[:flags].is_a? Array
|
|
27
|
-
config[:flags].push "FOUND_ROWS"
|
|
28
|
-
else
|
|
29
|
-
config[:flags] |= ::Mysql2::Client::FOUND_ROWS
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
mysql2_proxy_adapter_class.new(
|
|
33
|
-
mysql2_proxy_adapter_class.new_client(config),
|
|
34
|
-
logger,
|
|
35
|
-
nil,
|
|
36
|
-
config
|
|
37
|
-
)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
ActiveSupport.on_load(:active_record) do
|
|
44
|
-
ActiveRecord::Base.extend(ActiveRecordProxyAdapters::Mysql2::ConnectionHandling)
|
|
45
|
-
end
|
|
@@ -6,41 +6,3 @@ rescue LoadError
|
|
|
6
6
|
# Postgres not available
|
|
7
7
|
return
|
|
8
8
|
end
|
|
9
|
-
|
|
10
|
-
module ActiveRecordProxyAdapters
|
|
11
|
-
# Module to extend ActiveRecord::Base with the connection handling methods.
|
|
12
|
-
# Required to make adapter work in ActiveRecord versions <= 7.2.x
|
|
13
|
-
module PostgreSQL
|
|
14
|
-
module ConnectionHandling # rubocop:disable Style/Documentation
|
|
15
|
-
def postgresql_proxy_adapter_class
|
|
16
|
-
::ActiveRecord::ConnectionAdapters::PostgreSQLProxyAdapter
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# This method is a copy and paste from Rails' postgresql_connection,
|
|
20
|
-
# replacing PostgreSQLAdapter by PostgreSQLProxyAdapter
|
|
21
|
-
# This is required by ActiveRecord versions <= 7.2.x to establish a connection using the adapter.
|
|
22
|
-
def postgresql_proxy_connection(config) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
23
|
-
conn_params = config.symbolize_keys.compact
|
|
24
|
-
|
|
25
|
-
# Map ActiveRecords param names to PGs.
|
|
26
|
-
conn_params[:user] = conn_params.delete(:username) if conn_params[:username]
|
|
27
|
-
conn_params[:dbname] = conn_params.delete(:database) if conn_params[:database]
|
|
28
|
-
|
|
29
|
-
# Forward only valid config params to PG::Connection.connect.
|
|
30
|
-
valid_conn_param_keys = PG::Connection.conndefaults_hash.keys + [:requiressl]
|
|
31
|
-
conn_params.slice!(*valid_conn_param_keys)
|
|
32
|
-
|
|
33
|
-
postgresql_proxy_adapter_class.new(
|
|
34
|
-
postgresql_proxy_adapter_class.new_client(conn_params),
|
|
35
|
-
logger,
|
|
36
|
-
conn_params,
|
|
37
|
-
config
|
|
38
|
-
)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
ActiveSupport.on_load(:active_record) do
|
|
45
|
-
ActiveRecord::Base.extend(ActiveRecordProxyAdapters::PostgreSQL::ConnectionHandling)
|
|
46
|
-
end
|
|
@@ -6,23 +6,3 @@ rescue LoadError
|
|
|
6
6
|
# sqlite3 not available
|
|
7
7
|
return
|
|
8
8
|
end
|
|
9
|
-
|
|
10
|
-
module ActiveRecordProxyAdapters
|
|
11
|
-
module SQLite3
|
|
12
|
-
# Module to extend ActiveRecord::Base with the connection handling methods.
|
|
13
|
-
# Required to make adapter work in ActiveRecord versions <= 7.2.x
|
|
14
|
-
module ConnectionHandling
|
|
15
|
-
def sqlite3_proxy_adapter_class
|
|
16
|
-
ActiveRecord::ConnectionAdapters::SQLite3ProxyAdapter
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def sqlite3_proxy_connection(config)
|
|
20
|
-
sqlite3_proxy_adapter_class.new(config)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
ActiveSupport.on_load(:active_record) do
|
|
27
|
-
ActiveRecord::Base.extend(ActiveRecordProxyAdapters::SQLite3::ConnectionHandling)
|
|
28
|
-
end
|
|
@@ -6,39 +6,3 @@ rescue LoadError
|
|
|
6
6
|
# trilogy not available
|
|
7
7
|
return
|
|
8
8
|
end
|
|
9
|
-
|
|
10
|
-
module ActiveRecordProxyAdapters
|
|
11
|
-
module Trilogy
|
|
12
|
-
# Module to extend ActiveRecord::Base with the connection handling methods.
|
|
13
|
-
# Required to make adapter work in ActiveRecord versions <= 7.2.x
|
|
14
|
-
module ConnectionHandling
|
|
15
|
-
def trilogy_proxy_adapter_class
|
|
16
|
-
ActiveRecord::ConnectionAdapters::TrilogyProxyAdapter
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def trilogy_proxy_connection(config) # rubocop:disable Metrics/MethodLength
|
|
20
|
-
configuration = config.dup
|
|
21
|
-
|
|
22
|
-
# Set FOUND_ROWS capability on the connection so UPDATE queries returns number of rows
|
|
23
|
-
# matched rather than number of rows updated.
|
|
24
|
-
configuration[:found_rows] = true
|
|
25
|
-
|
|
26
|
-
options = [
|
|
27
|
-
configuration[:host],
|
|
28
|
-
configuration[:port],
|
|
29
|
-
configuration[:database],
|
|
30
|
-
configuration[:username],
|
|
31
|
-
configuration[:password],
|
|
32
|
-
configuration[:socket],
|
|
33
|
-
0
|
|
34
|
-
]
|
|
35
|
-
|
|
36
|
-
trilogy_proxy_adapter_class.new nil, logger, options, configuration
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
ActiveSupport.on_load(:active_record) do
|
|
43
|
-
ActiveRecord::Base.extend(ActiveRecordProxyAdapters::Trilogy::ConnectionHandling)
|
|
44
|
-
end
|
|
@@ -7,7 +7,6 @@ require "active_record_proxy_adapters/hijackable"
|
|
|
7
7
|
require "active_record_proxy_adapters/mixin/configuration"
|
|
8
8
|
require "active_support/core_ext/module/delegation"
|
|
9
9
|
require "active_support/core_ext/object/blank"
|
|
10
|
-
require "timeout"
|
|
11
10
|
|
|
12
11
|
module ActiveRecordProxyAdapters
|
|
13
12
|
# This is the base class for all proxies. It defines the methods that should be proxied
|
|
@@ -223,9 +222,8 @@ module ActiveRecordProxyAdapters
|
|
|
223
222
|
|
|
224
223
|
def match_sql?(sql_string)
|
|
225
224
|
proc do |matcher|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
rescue Timeout::Error
|
|
225
|
+
Regexp.new(matcher.source, Regexp::IGNORECASE, timeout: proxy_checkout_timeout.to_f).match?(sql_string)
|
|
226
|
+
rescue Regexp::TimeoutError
|
|
229
227
|
regexp_timeout_strategy.call(sql_string, matcher)
|
|
230
228
|
|
|
231
229
|
false
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_record_proxy_adapters
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Cruz
|
|
@@ -15,40 +15,40 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 7.
|
|
18
|
+
version: 7.2.0
|
|
19
19
|
- - "<"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: '8.
|
|
21
|
+
version: '8.2'
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
25
|
requirements:
|
|
26
26
|
- - ">="
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: 7.
|
|
28
|
+
version: 7.2.0
|
|
29
29
|
- - "<"
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
|
-
version: '8.
|
|
31
|
+
version: '8.2'
|
|
32
32
|
- !ruby/object:Gem::Dependency
|
|
33
33
|
name: activesupport
|
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
|
35
35
|
requirements:
|
|
36
36
|
- - ">="
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: 7.
|
|
38
|
+
version: 7.2.0
|
|
39
39
|
- - "<"
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '8.
|
|
41
|
+
version: '8.2'
|
|
42
42
|
type: :runtime
|
|
43
43
|
prerelease: false
|
|
44
44
|
version_requirements: !ruby/object:Gem::Requirement
|
|
45
45
|
requirements:
|
|
46
46
|
- - ">="
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: 7.
|
|
48
|
+
version: 7.2.0
|
|
49
49
|
- - "<"
|
|
50
50
|
- !ruby/object:Gem::Version
|
|
51
|
-
version: '8.
|
|
51
|
+
version: '8.2'
|
|
52
52
|
- !ruby/object:Gem::Dependency
|
|
53
53
|
name: digest
|
|
54
54
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -91,20 +91,6 @@ dependencies:
|
|
|
91
91
|
- - ">="
|
|
92
92
|
- !ruby/object:Gem::Version
|
|
93
93
|
version: '0'
|
|
94
|
-
- !ruby/object:Gem::Dependency
|
|
95
|
-
name: timeout
|
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
|
97
|
-
requirements:
|
|
98
|
-
- - ">="
|
|
99
|
-
- !ruby/object:Gem::Version
|
|
100
|
-
version: '0'
|
|
101
|
-
type: :runtime
|
|
102
|
-
prerelease: false
|
|
103
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
104
|
-
requirements:
|
|
105
|
-
- - ">="
|
|
106
|
-
- !ruby/object:Gem::Version
|
|
107
|
-
version: '0'
|
|
108
94
|
description: |-
|
|
109
95
|
This gem allows automatic connection switching between a primary and one read replica database in ActiveRecord.
|
|
110
96
|
It pattern matches the SQL statement being sent to decide whether it should go to the replica (SELECT) or the
|