active_record_proxy_adapters 0.3.4 → 0.4.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/.rspec +4 -0
- data/.rubocop.yml +18 -0
- data/Appraisals +25 -0
- data/CHANGELOG.md +49 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/Dockerfile +21 -0
- data/db/mysql_structure.sql +41 -0
- data/db/postgresql_structure.sql +86 -0
- data/docker/postgres_replica/cmd.sh +9 -0
- data/docker-compose.yml +98 -0
- data/gemfiles/rails_7.0.gemfile +25 -0
- data/gemfiles/rails_7.0.gemfile.lock +122 -0
- data/gemfiles/rails_7.1.gemfile +21 -0
- data/gemfiles/rails_7.1.gemfile.lock +131 -0
- data/gemfiles/rails_7.2.gemfile +21 -0
- data/gemfiles/rails_7.2.gemfile.lock +129 -0
- data/gemfiles/rails_8.0.gemfile +21 -0
- data/gemfiles/rails_8.0.gemfile.lock +131 -0
- data/lib/active_record/connection_adapters/mysql2_proxy_adapter.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql_proxy_adapter.rb +4 -1
- data/lib/active_record/connection_adapters/trilogy_proxy_adapter.rb +41 -0
- data/lib/active_record/tasks/trilogy_proxy_database_tasks.rb +19 -0
- data/lib/active_record_proxy_adapters/active_record_context.rb +0 -18
- data/lib/active_record_proxy_adapters/connection_handling/mysql2.rb +29 -23
- data/lib/active_record_proxy_adapters/connection_handling/postgresql.rb +27 -21
- data/lib/active_record_proxy_adapters/connection_handling/trilogy.rb +44 -0
- data/lib/active_record_proxy_adapters/connection_handling.rb +1 -7
- data/lib/active_record_proxy_adapters/primary_replica_proxy.rb +2 -19
- data/lib/active_record_proxy_adapters/railtie.rb +1 -4
- data/lib/active_record_proxy_adapters/trilogy_proxy.rb +9 -0
- data/lib/active_record_proxy_adapters/version.rb +1 -1
- data/postgres_primary.dockerfile +34 -0
- data/postgres_replica.dockerfile +15 -0
- data/sig/active_record_proxy_adapters.rbs +4 -0
- metadata +28 -5
@@ -0,0 +1,131 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
active_record_proxy_adapters (0.3.1)
|
5
|
+
activerecord (>= 7.0.0, < 8.1)
|
6
|
+
activesupport (>= 7.0.0, < 8.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (7.1.5.1)
|
12
|
+
activesupport (= 7.1.5.1)
|
13
|
+
activerecord (7.1.5.1)
|
14
|
+
activemodel (= 7.1.5.1)
|
15
|
+
activesupport (= 7.1.5.1)
|
16
|
+
timeout (>= 0.4.0)
|
17
|
+
activesupport (7.1.5.1)
|
18
|
+
base64
|
19
|
+
benchmark (>= 0.3)
|
20
|
+
bigdecimal
|
21
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
22
|
+
connection_pool (>= 2.2.5)
|
23
|
+
drb
|
24
|
+
i18n (>= 1.6, < 2)
|
25
|
+
logger (>= 1.4.2)
|
26
|
+
minitest (>= 5.1)
|
27
|
+
mutex_m
|
28
|
+
securerandom (>= 0.3)
|
29
|
+
tzinfo (~> 2.0)
|
30
|
+
appraisal (2.5.0)
|
31
|
+
bundler
|
32
|
+
rake
|
33
|
+
thor (>= 0.14.0)
|
34
|
+
ast (2.4.2)
|
35
|
+
base64 (0.2.0)
|
36
|
+
benchmark (0.4.0)
|
37
|
+
bigdecimal (3.1.9)
|
38
|
+
concurrent-ruby (1.3.5)
|
39
|
+
connection_pool (2.5.0)
|
40
|
+
diff-lcs (1.6.0)
|
41
|
+
docile (1.4.1)
|
42
|
+
drb (2.2.1)
|
43
|
+
i18n (1.14.7)
|
44
|
+
concurrent-ruby (~> 1.0)
|
45
|
+
json (2.10.1)
|
46
|
+
language_server-protocol (3.17.0.4)
|
47
|
+
lint_roller (1.1.0)
|
48
|
+
logger (1.6.6)
|
49
|
+
minitest (5.25.4)
|
50
|
+
mutex_m (0.3.0)
|
51
|
+
mysql2 (0.5.6)
|
52
|
+
parallel (1.26.3)
|
53
|
+
parser (3.3.7.1)
|
54
|
+
ast (~> 2.4.1)
|
55
|
+
racc
|
56
|
+
pg (1.5.9)
|
57
|
+
racc (1.8.1)
|
58
|
+
rainbow (3.1.1)
|
59
|
+
rake (13.2.1)
|
60
|
+
regexp_parser (2.10.0)
|
61
|
+
rexml (3.4.0)
|
62
|
+
rspec (3.13.0)
|
63
|
+
rspec-core (~> 3.13.0)
|
64
|
+
rspec-expectations (~> 3.13.0)
|
65
|
+
rspec-mocks (~> 3.13.0)
|
66
|
+
rspec-core (3.13.3)
|
67
|
+
rspec-support (~> 3.13.0)
|
68
|
+
rspec-expectations (3.13.3)
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
+
rspec-support (~> 3.13.0)
|
71
|
+
rspec-mocks (3.13.2)
|
72
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
73
|
+
rspec-support (~> 3.13.0)
|
74
|
+
rspec-support (3.13.2)
|
75
|
+
rubocop (1.72.2)
|
76
|
+
json (~> 2.3)
|
77
|
+
language_server-protocol (~> 3.17.0.2)
|
78
|
+
lint_roller (~> 1.1.0)
|
79
|
+
parallel (~> 1.10)
|
80
|
+
parser (>= 3.3.0.2)
|
81
|
+
rainbow (>= 2.2.2, < 4.0)
|
82
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
83
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
84
|
+
ruby-progressbar (~> 1.7)
|
85
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
86
|
+
rubocop-ast (1.38.0)
|
87
|
+
parser (>= 3.3.1.0)
|
88
|
+
rubocop-rspec (3.5.0)
|
89
|
+
lint_roller (~> 1.1)
|
90
|
+
rubocop (~> 1.72, >= 1.72.1)
|
91
|
+
ruby-progressbar (1.13.0)
|
92
|
+
securerandom (0.4.1)
|
93
|
+
simplecov (0.22.0)
|
94
|
+
docile (~> 1.1)
|
95
|
+
simplecov-html (~> 0.11)
|
96
|
+
simplecov_json_formatter (~> 0.1)
|
97
|
+
simplecov-cobertura (2.1.0)
|
98
|
+
rexml
|
99
|
+
simplecov (~> 0.19)
|
100
|
+
simplecov-html (0.13.1)
|
101
|
+
simplecov_json_formatter (0.1.4)
|
102
|
+
thor (1.3.2)
|
103
|
+
timeout (0.4.3)
|
104
|
+
trilogy (2.9.0)
|
105
|
+
tzinfo (2.0.6)
|
106
|
+
concurrent-ruby (~> 1.0)
|
107
|
+
unicode-display_width (3.1.4)
|
108
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
109
|
+
unicode-emoji (4.0.4)
|
110
|
+
|
111
|
+
PLATFORMS
|
112
|
+
aarch64-linux-musl
|
113
|
+
ruby
|
114
|
+
|
115
|
+
DEPENDENCIES
|
116
|
+
active_record_proxy_adapters!
|
117
|
+
activerecord (~> 7.1.0)
|
118
|
+
activesupport (~> 7.1.0)
|
119
|
+
appraisal
|
120
|
+
mysql2 (~> 0.5)
|
121
|
+
pg (~> 1.5)
|
122
|
+
rake (~> 13.0)
|
123
|
+
rspec (~> 3.0)
|
124
|
+
rubocop (~> 1.72)
|
125
|
+
rubocop-rspec (~> 3.5.0)
|
126
|
+
simplecov
|
127
|
+
simplecov-cobertura
|
128
|
+
trilogy (~> 2.9)
|
129
|
+
|
130
|
+
BUNDLED WITH
|
131
|
+
2.5.13
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "mysql2", "~> 0.5"
|
6
|
+
gem "pg", "~> 1.5"
|
7
|
+
gem "trilogy", "~> 2.9"
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem "appraisal"
|
10
|
+
gem "activerecord", "~> 7.2.0"
|
11
|
+
gem "activesupport", "~> 7.2.0"
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem "rspec", "~> 3.0"
|
15
|
+
gem "rubocop", "~> 1.72"
|
16
|
+
gem "rubocop-rspec", "~> 3.5.0"
|
17
|
+
gem "simplecov"
|
18
|
+
gem "simplecov-cobertura"
|
19
|
+
end
|
20
|
+
|
21
|
+
gemspec path: "../"
|
@@ -0,0 +1,129 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
active_record_proxy_adapters (0.3.1)
|
5
|
+
activerecord (>= 7.0.0, < 8.1)
|
6
|
+
activesupport (>= 7.0.0, < 8.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (7.2.2.1)
|
12
|
+
activesupport (= 7.2.2.1)
|
13
|
+
activerecord (7.2.2.1)
|
14
|
+
activemodel (= 7.2.2.1)
|
15
|
+
activesupport (= 7.2.2.1)
|
16
|
+
timeout (>= 0.4.0)
|
17
|
+
activesupport (7.2.2.1)
|
18
|
+
base64
|
19
|
+
benchmark (>= 0.3)
|
20
|
+
bigdecimal
|
21
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
22
|
+
connection_pool (>= 2.2.5)
|
23
|
+
drb
|
24
|
+
i18n (>= 1.6, < 2)
|
25
|
+
logger (>= 1.4.2)
|
26
|
+
minitest (>= 5.1)
|
27
|
+
securerandom (>= 0.3)
|
28
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
29
|
+
appraisal (2.5.0)
|
30
|
+
bundler
|
31
|
+
rake
|
32
|
+
thor (>= 0.14.0)
|
33
|
+
ast (2.4.2)
|
34
|
+
base64 (0.2.0)
|
35
|
+
benchmark (0.4.0)
|
36
|
+
bigdecimal (3.1.9)
|
37
|
+
concurrent-ruby (1.3.5)
|
38
|
+
connection_pool (2.5.0)
|
39
|
+
diff-lcs (1.6.0)
|
40
|
+
docile (1.4.1)
|
41
|
+
drb (2.2.1)
|
42
|
+
i18n (1.14.7)
|
43
|
+
concurrent-ruby (~> 1.0)
|
44
|
+
json (2.10.1)
|
45
|
+
language_server-protocol (3.17.0.4)
|
46
|
+
lint_roller (1.1.0)
|
47
|
+
logger (1.6.6)
|
48
|
+
minitest (5.25.4)
|
49
|
+
mysql2 (0.5.6)
|
50
|
+
parallel (1.26.3)
|
51
|
+
parser (3.3.7.1)
|
52
|
+
ast (~> 2.4.1)
|
53
|
+
racc
|
54
|
+
pg (1.5.9)
|
55
|
+
racc (1.8.1)
|
56
|
+
rainbow (3.1.1)
|
57
|
+
rake (13.2.1)
|
58
|
+
regexp_parser (2.10.0)
|
59
|
+
rexml (3.4.0)
|
60
|
+
rspec (3.13.0)
|
61
|
+
rspec-core (~> 3.13.0)
|
62
|
+
rspec-expectations (~> 3.13.0)
|
63
|
+
rspec-mocks (~> 3.13.0)
|
64
|
+
rspec-core (3.13.3)
|
65
|
+
rspec-support (~> 3.13.0)
|
66
|
+
rspec-expectations (3.13.3)
|
67
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
68
|
+
rspec-support (~> 3.13.0)
|
69
|
+
rspec-mocks (3.13.2)
|
70
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
+
rspec-support (~> 3.13.0)
|
72
|
+
rspec-support (3.13.2)
|
73
|
+
rubocop (1.72.2)
|
74
|
+
json (~> 2.3)
|
75
|
+
language_server-protocol (~> 3.17.0.2)
|
76
|
+
lint_roller (~> 1.1.0)
|
77
|
+
parallel (~> 1.10)
|
78
|
+
parser (>= 3.3.0.2)
|
79
|
+
rainbow (>= 2.2.2, < 4.0)
|
80
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
81
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
82
|
+
ruby-progressbar (~> 1.7)
|
83
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
84
|
+
rubocop-ast (1.38.0)
|
85
|
+
parser (>= 3.3.1.0)
|
86
|
+
rubocop-rspec (3.5.0)
|
87
|
+
lint_roller (~> 1.1)
|
88
|
+
rubocop (~> 1.72, >= 1.72.1)
|
89
|
+
ruby-progressbar (1.13.0)
|
90
|
+
securerandom (0.4.1)
|
91
|
+
simplecov (0.22.0)
|
92
|
+
docile (~> 1.1)
|
93
|
+
simplecov-html (~> 0.11)
|
94
|
+
simplecov_json_formatter (~> 0.1)
|
95
|
+
simplecov-cobertura (2.1.0)
|
96
|
+
rexml
|
97
|
+
simplecov (~> 0.19)
|
98
|
+
simplecov-html (0.13.1)
|
99
|
+
simplecov_json_formatter (0.1.4)
|
100
|
+
thor (1.3.2)
|
101
|
+
timeout (0.4.3)
|
102
|
+
trilogy (2.9.0)
|
103
|
+
tzinfo (2.0.6)
|
104
|
+
concurrent-ruby (~> 1.0)
|
105
|
+
unicode-display_width (3.1.4)
|
106
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
107
|
+
unicode-emoji (4.0.4)
|
108
|
+
|
109
|
+
PLATFORMS
|
110
|
+
aarch64-linux-musl
|
111
|
+
ruby
|
112
|
+
|
113
|
+
DEPENDENCIES
|
114
|
+
active_record_proxy_adapters!
|
115
|
+
activerecord (~> 7.2.0)
|
116
|
+
activesupport (~> 7.2.0)
|
117
|
+
appraisal
|
118
|
+
mysql2 (~> 0.5)
|
119
|
+
pg (~> 1.5)
|
120
|
+
rake (~> 13.0)
|
121
|
+
rspec (~> 3.0)
|
122
|
+
rubocop (~> 1.72)
|
123
|
+
rubocop-rspec (~> 3.5.0)
|
124
|
+
simplecov
|
125
|
+
simplecov-cobertura
|
126
|
+
trilogy (~> 2.9)
|
127
|
+
|
128
|
+
BUNDLED WITH
|
129
|
+
2.5.13
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "mysql2", "~> 0.5"
|
6
|
+
gem "pg", "~> 1.5"
|
7
|
+
gem "trilogy", "~> 2.9"
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem "appraisal"
|
10
|
+
gem "activerecord", "~> 8.0.0"
|
11
|
+
gem "activesupport", "~> 8.0.0"
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem "rspec", "~> 3.0"
|
15
|
+
gem "rubocop", "~> 1.72"
|
16
|
+
gem "rubocop-rspec", "~> 3.5.0"
|
17
|
+
gem "simplecov"
|
18
|
+
gem "simplecov-cobertura"
|
19
|
+
end
|
20
|
+
|
21
|
+
gemspec path: "../"
|
@@ -0,0 +1,131 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
active_record_proxy_adapters (0.3.1)
|
5
|
+
activerecord (>= 7.0.0, < 8.1)
|
6
|
+
activesupport (>= 7.0.0, < 8.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (8.0.1)
|
12
|
+
activesupport (= 8.0.1)
|
13
|
+
activerecord (8.0.1)
|
14
|
+
activemodel (= 8.0.1)
|
15
|
+
activesupport (= 8.0.1)
|
16
|
+
timeout (>= 0.4.0)
|
17
|
+
activesupport (8.0.1)
|
18
|
+
base64
|
19
|
+
benchmark (>= 0.3)
|
20
|
+
bigdecimal
|
21
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
22
|
+
connection_pool (>= 2.2.5)
|
23
|
+
drb
|
24
|
+
i18n (>= 1.6, < 2)
|
25
|
+
logger (>= 1.4.2)
|
26
|
+
minitest (>= 5.1)
|
27
|
+
securerandom (>= 0.3)
|
28
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
29
|
+
uri (>= 0.13.1)
|
30
|
+
appraisal (2.5.0)
|
31
|
+
bundler
|
32
|
+
rake
|
33
|
+
thor (>= 0.14.0)
|
34
|
+
ast (2.4.2)
|
35
|
+
base64 (0.2.0)
|
36
|
+
benchmark (0.4.0)
|
37
|
+
bigdecimal (3.1.9)
|
38
|
+
concurrent-ruby (1.3.5)
|
39
|
+
connection_pool (2.5.0)
|
40
|
+
diff-lcs (1.6.0)
|
41
|
+
docile (1.4.1)
|
42
|
+
drb (2.2.1)
|
43
|
+
i18n (1.14.7)
|
44
|
+
concurrent-ruby (~> 1.0)
|
45
|
+
json (2.10.1)
|
46
|
+
language_server-protocol (3.17.0.4)
|
47
|
+
lint_roller (1.1.0)
|
48
|
+
logger (1.6.6)
|
49
|
+
minitest (5.25.4)
|
50
|
+
mysql2 (0.5.6)
|
51
|
+
parallel (1.26.3)
|
52
|
+
parser (3.3.7.1)
|
53
|
+
ast (~> 2.4.1)
|
54
|
+
racc
|
55
|
+
pg (1.5.9)
|
56
|
+
racc (1.8.1)
|
57
|
+
rainbow (3.1.1)
|
58
|
+
rake (13.2.1)
|
59
|
+
regexp_parser (2.10.0)
|
60
|
+
rexml (3.4.0)
|
61
|
+
rspec (3.13.0)
|
62
|
+
rspec-core (~> 3.13.0)
|
63
|
+
rspec-expectations (~> 3.13.0)
|
64
|
+
rspec-mocks (~> 3.13.0)
|
65
|
+
rspec-core (3.13.3)
|
66
|
+
rspec-support (~> 3.13.0)
|
67
|
+
rspec-expectations (3.13.3)
|
68
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
+
rspec-support (~> 3.13.0)
|
70
|
+
rspec-mocks (3.13.2)
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
72
|
+
rspec-support (~> 3.13.0)
|
73
|
+
rspec-support (3.13.2)
|
74
|
+
rubocop (1.72.2)
|
75
|
+
json (~> 2.3)
|
76
|
+
language_server-protocol (~> 3.17.0.2)
|
77
|
+
lint_roller (~> 1.1.0)
|
78
|
+
parallel (~> 1.10)
|
79
|
+
parser (>= 3.3.0.2)
|
80
|
+
rainbow (>= 2.2.2, < 4.0)
|
81
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
82
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
83
|
+
ruby-progressbar (~> 1.7)
|
84
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
85
|
+
rubocop-ast (1.38.0)
|
86
|
+
parser (>= 3.3.1.0)
|
87
|
+
rubocop-rspec (3.5.0)
|
88
|
+
lint_roller (~> 1.1)
|
89
|
+
rubocop (~> 1.72, >= 1.72.1)
|
90
|
+
ruby-progressbar (1.13.0)
|
91
|
+
securerandom (0.4.1)
|
92
|
+
simplecov (0.22.0)
|
93
|
+
docile (~> 1.1)
|
94
|
+
simplecov-html (~> 0.11)
|
95
|
+
simplecov_json_formatter (~> 0.1)
|
96
|
+
simplecov-cobertura (2.1.0)
|
97
|
+
rexml
|
98
|
+
simplecov (~> 0.19)
|
99
|
+
simplecov-html (0.13.1)
|
100
|
+
simplecov_json_formatter (0.1.4)
|
101
|
+
thor (1.3.2)
|
102
|
+
timeout (0.4.3)
|
103
|
+
trilogy (2.9.0)
|
104
|
+
tzinfo (2.0.6)
|
105
|
+
concurrent-ruby (~> 1.0)
|
106
|
+
unicode-display_width (3.1.4)
|
107
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
108
|
+
unicode-emoji (4.0.4)
|
109
|
+
uri (1.0.2)
|
110
|
+
|
111
|
+
PLATFORMS
|
112
|
+
aarch64-linux-musl
|
113
|
+
ruby
|
114
|
+
|
115
|
+
DEPENDENCIES
|
116
|
+
active_record_proxy_adapters!
|
117
|
+
activerecord (~> 8.0.0)
|
118
|
+
activesupport (~> 8.0.0)
|
119
|
+
appraisal
|
120
|
+
mysql2 (~> 0.5)
|
121
|
+
pg (~> 1.5)
|
122
|
+
rake (~> 13.0)
|
123
|
+
rspec (~> 3.0)
|
124
|
+
rubocop (~> 1.72)
|
125
|
+
rubocop-rspec (~> 3.5.0)
|
126
|
+
simplecov
|
127
|
+
simplecov-cobertura
|
128
|
+
trilogy (~> 2.9)
|
129
|
+
|
130
|
+
BUNDLED WITH
|
131
|
+
2.5.13
|
@@ -15,7 +15,7 @@ module ActiveRecord
|
|
15
15
|
|
16
16
|
ADAPTER_NAME = "Mysql2Proxy"
|
17
17
|
|
18
|
-
delegate_to_proxy
|
18
|
+
delegate_to_proxy :execute, :exec_query
|
19
19
|
|
20
20
|
def initialize(...)
|
21
21
|
@proxy = ActiveRecordProxyAdapters::Mysql2Proxy.new(self)
|
@@ -37,3 +37,5 @@ if ActiveRecordProxyAdapters::ActiveRecordContext.active_record_v7_2_or_greater?
|
|
37
37
|
"active_record/connection_adapters/mysql2_proxy_adapter"
|
38
38
|
)
|
39
39
|
end
|
40
|
+
|
41
|
+
ActiveSupport.run_load_hooks(:active_record_mysql2proxyadapter, ActiveRecord::ConnectionAdapters::Mysql2ProxyAdapter)
|
@@ -15,7 +15,7 @@ module ActiveRecord
|
|
15
15
|
|
16
16
|
ADAPTER_NAME = "PostgreSQLProxy"
|
17
17
|
|
18
|
-
delegate_to_proxy
|
18
|
+
delegate_to_proxy :execute, :exec_query
|
19
19
|
|
20
20
|
unless ActiveRecordProxyAdapters::ActiveRecordContext.active_record_v8_0_or_greater?
|
21
21
|
delegate_to_proxy :exec_no_cache, :exec_cache
|
@@ -41,3 +41,6 @@ if ActiveRecordProxyAdapters::ActiveRecordContext.active_record_v7_2_or_greater?
|
|
41
41
|
"active_record/connection_adapters/postgresql_proxy_adapter"
|
42
42
|
)
|
43
43
|
end
|
44
|
+
|
45
|
+
ActiveSupport.run_load_hooks(:active_record_postgresqlproxyadapter,
|
46
|
+
ActiveRecord::ConnectionAdapters::PostgreSQLProxyAdapter)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_record/tasks/trilogy_proxy_database_tasks"
|
4
|
+
require "active_record/connection_adapters/trilogy_adapter"
|
5
|
+
require "active_record_proxy_adapters/active_record_context"
|
6
|
+
require "active_record_proxy_adapters/hijackable"
|
7
|
+
require "active_record_proxy_adapters/trilogy_proxy"
|
8
|
+
|
9
|
+
module ActiveRecord
|
10
|
+
module ConnectionAdapters
|
11
|
+
# This adapter is a proxy to the original TrilogyAdapter, allowing the use of the
|
12
|
+
# ActiveRecordProxyAdapters::PrimaryReplicaProxy.
|
13
|
+
class TrilogyProxyAdapter < TrilogyAdapter
|
14
|
+
include ActiveRecordProxyAdapters::Hijackable
|
15
|
+
|
16
|
+
ADAPTER_NAME = "TrilogyProxy"
|
17
|
+
|
18
|
+
delegate_to_proxy :execute, :exec_query
|
19
|
+
|
20
|
+
def initialize(...)
|
21
|
+
@proxy = ActiveRecordProxyAdapters::TrilogyProxy.new(self)
|
22
|
+
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :proxy
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
if ActiveRecordProxyAdapters::ActiveRecordContext.active_record_v7_2_or_greater?
|
34
|
+
ActiveRecord::ConnectionAdapters.register(
|
35
|
+
"trilogy_proxy",
|
36
|
+
"ActiveRecord::ConnectionAdapters::TrilogyProxyAdapter",
|
37
|
+
"active_record/connection_adapters/trilogy_proxy_adapter"
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
ActiveSupport.run_load_hooks(:active_record_trilogyproxyadapter, ActiveRecord::ConnectionAdapters::TrilogyProxyAdapter)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_record_proxy_adapters/database_tasks"
|
4
|
+
|
5
|
+
module ActiveRecord
|
6
|
+
module Tasks
|
7
|
+
# Defines the trilogy tasks for dropping, creating, loading schema and dumping schema.
|
8
|
+
# Bypasses all the proxy logic to send all requests to primary.
|
9
|
+
class TrilogyProxyDatabaseTasks < MySQLDatabaseTasks
|
10
|
+
include ActiveRecordProxyAdapters::DatabaseTasks
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Allow proxy adapter to run rake tasks, i.e. db:drop, db:create, db:schema:load db:migrate, etc...
|
16
|
+
ActiveRecord::Tasks::DatabaseTasks.register_task(
|
17
|
+
/trilogy_proxy/,
|
18
|
+
"ActiveRecord::Tasks::TrilogyProxyDatabaseTasks"
|
19
|
+
)
|
@@ -23,8 +23,6 @@ module ActiveRecordProxyAdapters
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def connection_class_for(connection)
|
26
|
-
return connection.connection_descriptor.name.constantize if active_record_v8_0_2_or_greater?
|
27
|
-
|
28
26
|
connection.connection_class || ActiveRecord::Base
|
29
27
|
end
|
30
28
|
|
@@ -35,18 +33,6 @@ module ActiveRecordProxyAdapters
|
|
35
33
|
ActiveRecord
|
36
34
|
end
|
37
35
|
|
38
|
-
def hijackable_methods
|
39
|
-
hijackable = %i[execute exec_query]
|
40
|
-
|
41
|
-
hijackable << :internal_exec_query if active_record_v8_0_or_greater?
|
42
|
-
|
43
|
-
hijackable
|
44
|
-
end
|
45
|
-
|
46
|
-
def active_record_v7?
|
47
|
-
active_record_version >= Gem::Version.new("7.0") && active_record_version < Gem::Version.new("8.0")
|
48
|
-
end
|
49
|
-
|
50
36
|
def active_record_v7_1_or_greater?
|
51
37
|
active_record_version >= Gem::Version.new("7.1")
|
52
38
|
end
|
@@ -58,9 +44,5 @@ module ActiveRecordProxyAdapters
|
|
58
44
|
def active_record_v8_0_or_greater?
|
59
45
|
active_record_version >= Gem::Version.new("8.0")
|
60
46
|
end
|
61
|
-
|
62
|
-
def active_record_v8_0_2_or_greater?
|
63
|
-
active_record_version >= Gem::Version.new("8.0.2")
|
64
|
-
end
|
65
47
|
end
|
66
48
|
end
|
@@ -8,32 +8,38 @@ rescue LoadError
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module ActiveRecordProxyAdapters
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
if config[:flags].is_a? Array
|
27
|
+
config[:flags].push "FOUND_ROWS"
|
28
|
+
else
|
29
|
+
config[:flags] |= ::Mysql2::Client::FOUND_ROWS
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
mysql2_proxy_adapter_class.new(
|
33
|
+
mysql2_proxy_adapter_class.new_client(config),
|
34
|
+
logger,
|
35
|
+
nil,
|
36
|
+
config
|
37
|
+
)
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
42
|
+
|
43
|
+
ActiveSupport.on_load(:active_record) do
|
44
|
+
ActiveRecord::Base.extend(ActiveRecordProxyAdapters::Mysql2::ConnectionHandling)
|
45
|
+
end
|
@@ -10,31 +10,37 @@ end
|
|
10
10
|
module ActiveRecordProxyAdapters
|
11
11
|
# Module to extend ActiveRecord::Base with the connection handling methods.
|
12
12
|
# Required to make adapter work in ActiveRecord versions <= 7.2.x
|
13
|
-
module
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
module PostgreSQL
|
14
|
+
module ConnectionHandling # rubocop:disable Style/Documentation
|
15
|
+
def postgresql_proxy_adapter_class
|
16
|
+
::ActiveRecord::ConnectionAdapters::PostgreSQLProxyAdapter
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
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]
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
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)
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
43
|
+
|
44
|
+
ActiveSupport.on_load(:active_record) do
|
45
|
+
ActiveRecord::Base.extend(ActiveRecordProxyAdapters::PostgreSQL::ConnectionHandling)
|
46
|
+
end
|