active_record_proxy_adapters 0.5.0 → 0.5.1
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/connection_adapters/mysql2_proxy_adapter.rb +8 -2
- data/lib/active_record/connection_adapters/postgresql_proxy_adapter.rb +8 -2
- data/lib/active_record/connection_adapters/trilogy_proxy_adapter.rb +8 -2
- data/lib/active_record_proxy_adapters/active_record_context.rb +4 -0
- data/lib/active_record_proxy_adapters/hijackable.rb +4 -2
- data/lib/active_record_proxy_adapters/primary_replica_proxy.rb +1 -0
- data/lib/active_record_proxy_adapters/transactionable_proxy_a_r_70.rb +31 -0
- data/lib/active_record_proxy_adapters/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f602b2e618bfa8bee550c356a04c26765f0b7f6de8548dbf9006fa171b059bd
|
4
|
+
data.tar.gz: 80a64f8b414f5596e94d62a71464cc7474937537127d7eac9696c2d00d1b8dc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 694af5bf60c0d9e9beb8025de3165eed8dfa0f52fc16620f1b9abd35719a4551db3507e9cb1e3c3570ce8e23b1078a0f0f3fa7586b032891a787d7de0628b8b7
|
7
|
+
data.tar.gz: 294760fea09b8fa86016ea19fc2b6d42e064861ecdeab3343a46c35de5a8203f4ac79a589353e1a8f5aa783e06c84c67ceb6805469c2aa2383d8ea941e193b43
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_record/tasks/mysql2_proxy_database_tasks"
|
4
|
-
require "active_record/connection_adapters/mysql2_adapter"
|
5
3
|
require "active_record_proxy_adapters/active_record_context"
|
6
4
|
require "active_record_proxy_adapters/hijackable"
|
7
5
|
require "active_record_proxy_adapters/mysql2_proxy"
|
6
|
+
require "active_record/connection_adapters/mysql2_adapter"
|
7
|
+
require "active_record/tasks/mysql2_proxy_database_tasks"
|
8
8
|
|
9
9
|
module ActiveRecord
|
10
10
|
module ConnectionAdapters
|
@@ -13,6 +13,12 @@ module ActiveRecord
|
|
13
13
|
class Mysql2ProxyAdapter < Mysql2Adapter
|
14
14
|
include ActiveRecordProxyAdapters::Hijackable
|
15
15
|
|
16
|
+
if ActiveRecordProxyAdapters::ActiveRecordContext.active_record_v7_0?
|
17
|
+
require "active_record_proxy_adapters/transactionable_proxy_a_r_70"
|
18
|
+
|
19
|
+
include ActiveRecordProxyAdapters::TransactionableProxyAR70
|
20
|
+
end
|
21
|
+
|
16
22
|
ADAPTER_NAME = "Mysql2Proxy"
|
17
23
|
|
18
24
|
delegate_to_proxy(*ActiveRecordProxyAdapters::ActiveRecordContext.hijackable_methods)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_record/tasks/postgresql_proxy_database_tasks"
|
4
|
-
require "active_record/connection_adapters/postgresql_adapter"
|
5
3
|
require "active_record_proxy_adapters/active_record_context"
|
6
4
|
require "active_record_proxy_adapters/hijackable"
|
7
5
|
require "active_record_proxy_adapters/postgresql_proxy"
|
6
|
+
require "active_record/connection_adapters/postgresql_adapter"
|
7
|
+
require "active_record/tasks/postgresql_proxy_database_tasks"
|
8
8
|
|
9
9
|
module ActiveRecord
|
10
10
|
module ConnectionAdapters
|
@@ -13,6 +13,12 @@ module ActiveRecord
|
|
13
13
|
class PostgreSQLProxyAdapter < PostgreSQLAdapter
|
14
14
|
include ActiveRecordProxyAdapters::Hijackable
|
15
15
|
|
16
|
+
if ActiveRecordProxyAdapters::ActiveRecordContext.active_record_v7_0?
|
17
|
+
require "active_record_proxy_adapters/transactionable_proxy_a_r_70"
|
18
|
+
|
19
|
+
include ActiveRecordProxyAdapters::TransactionableProxyAR70
|
20
|
+
end
|
21
|
+
|
16
22
|
ADAPTER_NAME = "PostgreSQLProxy"
|
17
23
|
|
18
24
|
delegate_to_proxy(*ActiveRecordProxyAdapters::ActiveRecordContext.hijackable_methods)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_record/tasks/trilogy_proxy_database_tasks"
|
4
|
-
require "active_record/connection_adapters/trilogy_adapter"
|
5
3
|
require "active_record_proxy_adapters/active_record_context"
|
6
4
|
require "active_record_proxy_adapters/hijackable"
|
7
5
|
require "active_record_proxy_adapters/trilogy_proxy"
|
6
|
+
require "active_record/connection_adapters/trilogy_adapter"
|
7
|
+
require "active_record/tasks/trilogy_proxy_database_tasks"
|
8
8
|
|
9
9
|
module ActiveRecord
|
10
10
|
module ConnectionAdapters
|
@@ -13,6 +13,12 @@ module ActiveRecord
|
|
13
13
|
class TrilogyProxyAdapter < TrilogyAdapter
|
14
14
|
include ActiveRecordProxyAdapters::Hijackable
|
15
15
|
|
16
|
+
if ActiveRecordProxyAdapters::ActiveRecordContext.active_record_v7_0?
|
17
|
+
require "active_record_proxy_adapters/transactionable_proxy_a_r_70"
|
18
|
+
|
19
|
+
include ActiveRecordProxyAdapters::TransactionableProxyAR70
|
20
|
+
end
|
21
|
+
|
16
22
|
ADAPTER_NAME = "TrilogyProxy"
|
17
23
|
|
18
24
|
delegate_to_proxy(*ActiveRecordProxyAdapters::ActiveRecordContext.hijackable_methods)
|
@@ -47,6 +47,10 @@ module ActiveRecordProxyAdapters
|
|
47
47
|
active_record_version >= Gem::Version.new("7.0") && active_record_version < Gem::Version.new("8.0")
|
48
48
|
end
|
49
49
|
|
50
|
+
def active_record_v7_0?
|
51
|
+
active_record_version >= Gem::Version.new("7.0") && active_record_version < Gem::Version.new("7.1")
|
52
|
+
end
|
53
|
+
|
50
54
|
def active_record_v7_1_or_greater?
|
51
55
|
active_record_version >= Gem::Version.new("7.1")
|
52
56
|
end
|
@@ -52,8 +52,6 @@ module ActiveRecordProxyAdapters
|
|
52
52
|
"_unproxied"
|
53
53
|
end
|
54
54
|
|
55
|
-
private
|
56
|
-
|
57
55
|
def proxy_method_name_for(method_name)
|
58
56
|
:"#{method_name}#{unproxied_method_suffix}"
|
59
57
|
end
|
@@ -63,6 +61,10 @@ module ActiveRecordProxyAdapters
|
|
63
61
|
def unproxied_method_suffix
|
64
62
|
self.class.unproxied_method_suffix
|
65
63
|
end
|
64
|
+
|
65
|
+
def proxy_method_name_for(method_name)
|
66
|
+
self.class.proxy_method_name_for(method_name)
|
67
|
+
end
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRecordProxyAdapters
|
4
|
+
module TransactionableProxyAR70 # rubocop:disable Style/Documentation
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
def begin_db_transaction # :nodoc:
|
9
|
+
bypass_proxy_or_else("BEGIN", "TRANSACTION") { super }
|
10
|
+
end
|
11
|
+
|
12
|
+
def commit_db_transaction # :nodoc:
|
13
|
+
bypass_proxy_or_else("COMMIT", "TRANSACTION") { super }
|
14
|
+
end
|
15
|
+
|
16
|
+
def exec_rollback_db_transaction # :nodoc:
|
17
|
+
bypass_proxy_or_else("ROLLBACK", "TRANSACTION") { super }
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def bypass_proxy_or_else(*args)
|
23
|
+
method_name = proxy_method_name_for(:execute)
|
24
|
+
|
25
|
+
return public_send(method_name, *args) if respond_to?(method_name)
|
26
|
+
|
27
|
+
yield
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_proxy_adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Cruz
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activerecord
|
@@ -58,8 +58,8 @@ email:
|
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files:
|
61
|
-
- README.md
|
62
61
|
- LICENSE.txt
|
62
|
+
- README.md
|
63
63
|
files:
|
64
64
|
- LICENSE.txt
|
65
65
|
- README.md
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/active_record_proxy_adapters/primary_replica_proxy.rb
|
88
88
|
- lib/active_record_proxy_adapters/railtie.rb
|
89
89
|
- lib/active_record_proxy_adapters/sqlite3_proxy.rb
|
90
|
+
- lib/active_record_proxy_adapters/transactionable_proxy_a_r_70.rb
|
90
91
|
- lib/active_record_proxy_adapters/trilogy_proxy.rb
|
91
92
|
- lib/active_record_proxy_adapters/version.rb
|
92
93
|
homepage: https://github.com/Nasdaq/active_record_proxy_adapters
|
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
113
|
- !ruby/object:Gem::Version
|
113
114
|
version: '0'
|
114
115
|
requirements: []
|
115
|
-
rubygems_version: 3.6.
|
116
|
+
rubygems_version: 3.6.9
|
116
117
|
specification_version: 4
|
117
118
|
summary: Read replica proxy adapters for ActiveRecord!
|
118
119
|
test_files: []
|