active_record_proxy_adapters 0.1.0.rc2 → 0.1.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.
Potentially problematic release.
This version of active_record_proxy_adapters might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/ci/stages/build.yml +91 -0
- data/ci/stages/env_vars.yml +18 -0
- data/ci/stages/lint.yml +12 -0
- data/ci/stages/prebuild.yml +28 -0
- data/ci/stages/push.yml +23 -0
- data/ci/stages/test.yml +133 -0
- data/lib/active_record/connection_adapters/postgresql_proxy_adapter.rb +8 -3
- data/lib/active_record_proxy_adapters/active_record_context.rb +10 -28
- data/lib/active_record_proxy_adapters/postgresql_proxy.rb +4 -1
- data/lib/active_record_proxy_adapters/primary_replica_proxy.rb +8 -1
- data/lib/active_record_proxy_adapters/version.rb +1 -1
- metadata +17 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f1bd3461586c7443e358fe82092039c05dd7cba760b4e4b7660ce6ecbd928e4
|
4
|
+
data.tar.gz: a8b40dce128c9449744ef8725bc6baa446ba8f4119e64c068a3d553e74b6fd1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a50dc55929c1d7c57f5278788d23240314660eba4ceb17335ac079740265b77042a35900ab64482073fabf79cc0612a7a38de9521f0cf5676a30b6545c5811a
|
7
|
+
data.tar.gz: 35ec9da8d5d1f4703129e66fa79f2f872bf5e36e053b38ea5abb25383e11980bbb19febee7c579d4e7b9905971b99e58be15d748ca13bafa064470bd873cc138
|
data/CHANGELOG.md
CHANGED
data/ci/stages/build.yml
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
.build_app_base:
|
2
|
+
extends: .build_base
|
3
|
+
stage: build
|
4
|
+
variables:
|
5
|
+
DOCKERFILE: Dockerfile
|
6
|
+
DOCKER_REGISTRY: registry.git.nasdaq.com/smp/common
|
7
|
+
rules:
|
8
|
+
- changes:
|
9
|
+
- Dockerfile
|
10
|
+
- Gemfile
|
11
|
+
- active_record_proxy_adapters.gemspec
|
12
|
+
- ci/stages/build.yml
|
13
|
+
retry: 2
|
14
|
+
script:
|
15
|
+
- echo "CI_JOB_NAME=${CI_JOB_NAME}"
|
16
|
+
- SUFFIX="-rails${RAILS_VERSION}-ruby${RUBY_VERSION}"
|
17
|
+
- SUFFIX=$(echo $SUFFIX | tr -d '~> ' | tr -d '>=' | tr -d '<=' | tr -d '>' | tr -d '<' | tr -d ' ' )
|
18
|
+
- APP_IMAGE=${ENV_IMAGE_PREFIX}${SUFFIX}
|
19
|
+
- echo "APP_IMAGE=${APP_IMAGE}"
|
20
|
+
- echo "RAILS_VERSION=${RAILS_VERSION}"
|
21
|
+
- echo "RUBY_VERSION=${RUBY_VERSION}"
|
22
|
+
- buildah_build -t $APP_IMAGE --build-arg DOCKER_REGISTRY="${DOCKER_REGISTRY}" --build-arg RUBY_VERSION="${RUBY_VERSION}" --build-arg RAILS_VERSION="${RAILS_VERSION}" -f $DOCKERFILE .
|
23
|
+
- buildah push $APP_IMAGE
|
24
|
+
|
25
|
+
env-rails-7.0.x 316 / 3:
|
26
|
+
extends: .build_app_base
|
27
|
+
variables:
|
28
|
+
RAILS_VERSION: '~> 7.0.0'
|
29
|
+
RUBY_VERSION: '3.1.6'
|
30
|
+
|
31
|
+
env-rails-7.0.x 325 / 3:
|
32
|
+
extends: .build_app_base
|
33
|
+
variables:
|
34
|
+
RAILS_VERSION: '~> 7.0.0'
|
35
|
+
RUBY_VERSION: '3.2.5'
|
36
|
+
|
37
|
+
env-rails-7.0.x 335 / 3:
|
38
|
+
extends: .build_app_base
|
39
|
+
variables:
|
40
|
+
RAILS_VERSION: '~> 7.0.0'
|
41
|
+
RUBY_VERSION: '3.3.5'
|
42
|
+
|
43
|
+
env-rails-7.1.x 316 / 3:
|
44
|
+
extends: .build_app_base
|
45
|
+
variables:
|
46
|
+
RAILS_VERSION: '~> 7.1.0'
|
47
|
+
RUBY_VERSION: '3.1.6'
|
48
|
+
|
49
|
+
env-rails-7.1.x 325 / 3:
|
50
|
+
extends: .build_app_base
|
51
|
+
variables:
|
52
|
+
RAILS_VERSION: '~> 7.1.0'
|
53
|
+
RUBY_VERSION: '3.2.5'
|
54
|
+
|
55
|
+
env-rails-7.1.x 335 / 3:
|
56
|
+
extends: .build_app_base
|
57
|
+
variables:
|
58
|
+
RUBY_VERSION: '3.3.5'
|
59
|
+
RAILS_VERSION: '~> 7.1.0'
|
60
|
+
|
61
|
+
env-rails-7.2.x 316 / 3:
|
62
|
+
extends: .build_app_base
|
63
|
+
variables:
|
64
|
+
RAILS_VERSION: '~> 7.2.0'
|
65
|
+
RUBY_VERSION: '3.1.6'
|
66
|
+
|
67
|
+
env-rails-7.2.x 325 / 3:
|
68
|
+
extends: .build_app_base
|
69
|
+
variables:
|
70
|
+
RAILS_VERSION: '~> 7.2.0'
|
71
|
+
RUBY_VERSION: '3.2.5'
|
72
|
+
|
73
|
+
env-rails-7.2.x 335 / 3:
|
74
|
+
extends: .build_app_base
|
75
|
+
variables:
|
76
|
+
RAILS_VERSION: '~> 7.2.0'
|
77
|
+
RUBY_VERSION: '3.3.5'
|
78
|
+
|
79
|
+
# Rails 8.0.x does not support Ruby 3.1.6
|
80
|
+
|
81
|
+
env-rails-8.0.x 325 / 3:
|
82
|
+
extends: .build_app_base
|
83
|
+
variables:
|
84
|
+
RAILS_VERSION: '~> 8.0.0'
|
85
|
+
RUBY_VERSION: '3.2.5'
|
86
|
+
|
87
|
+
env-rails-8.0.x 335 / 3:
|
88
|
+
extends: .build_app_base
|
89
|
+
variables:
|
90
|
+
RAILS_VERSION: '~> 8.0.0'
|
91
|
+
RUBY_VERSION: '3.3.5'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export:
|
2
|
+
stage: env_vars
|
3
|
+
image: registry.git.nasdaq.com/gitlab/ci/buildah/stable:v1.30.0
|
4
|
+
artifacts:
|
5
|
+
reports:
|
6
|
+
dotenv: build.env
|
7
|
+
script:
|
8
|
+
- !reference [.checksums, functions]
|
9
|
+
- POSTGRES_PRIMARY_TAG=$(checksum postgres_primary.dockerfile)
|
10
|
+
- POSTGRES_REPLICA_TAG=$(checksum postgres_replica.dockerfile)
|
11
|
+
- DOCKERFILE_CHECKSUM=$(checksum Dockerfile)
|
12
|
+
- GEMFILE_CHECKSUM=$(checksum Gemfile)
|
13
|
+
- GEMSPEC_CHECKSUM=$(checksum active_record_proxy_adapters.gemspec)
|
14
|
+
- TAG_PREFIX=$(checksum_join $DOCKERFILE_CHECKSUM $GEMFILE_CHECKSUM $GEMSPEC_CHECKSUM)
|
15
|
+
- ENV_IMAGE_PREFIX=${CI_REGISTRY_IMAGE}/env:${TAG_PREFIX}
|
16
|
+
- echo "POSTGRES_PRIMARY_IMAGE=${CI_REGISTRY_IMAGE}/postgres_primary:${POSTGRES_PRIMARY_TAG}" >> build.env
|
17
|
+
- echo "POSTGRES_REPLICA_IMAGE=${CI_REGISTRY_IMAGE}/postgres_replica:${POSTGRES_REPLICA_TAG}" >> build.env
|
18
|
+
- echo "ENV_IMAGE_PREFIX=${ENV_IMAGE_PREFIX}" >> build.env
|
data/ci/stages/lint.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
postgres_primary:
|
4
|
+
extends: .build_base
|
5
|
+
stage: prebuild
|
6
|
+
variables:
|
7
|
+
DOCKERFILE: postgres_primary.dockerfile
|
8
|
+
REPLICA_USER: replicator
|
9
|
+
REPLICA_PASSWORD: replicator
|
10
|
+
script:
|
11
|
+
- echo "POSTGRES_PRIMARY_IMAGE=${POSTGRES_PRIMARY_IMAGE}"
|
12
|
+
- echo "DOCKERFILE=${DOCKERFILE}"
|
13
|
+
- buildah_build -t $POSTGRES_PRIMARY_IMAGE --build-arg REPLICA_USER=${REPLICA_USER} --build-arg REPLICA_PASSWORD=${REPLICA_PASSWORD} -f $DOCKERFILE .
|
14
|
+
- buildah push $POSTGRES_PRIMARY_IMAGE
|
15
|
+
rules:
|
16
|
+
- changes:
|
17
|
+
- postgres_primary.dockerfile
|
18
|
+
postgres_replica:
|
19
|
+
extends: .build_base
|
20
|
+
stage: prebuild
|
21
|
+
variables:
|
22
|
+
DOCKERFILE: postgres_replica.dockerfile
|
23
|
+
script:
|
24
|
+
- buildah_build -t $POSTGRES_REPLICA_IMAGE -f $DOCKERFILE .
|
25
|
+
- buildah push $POSTGRES_REPLICA_IMAGE
|
26
|
+
rules:
|
27
|
+
- changes:
|
28
|
+
- postgres_replica.dockerfile
|
data/ci/stages/push.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
push_to_rubygems:
|
2
|
+
stage: push
|
3
|
+
image: ruby:alpine
|
4
|
+
rules:
|
5
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
6
|
+
when: manual
|
7
|
+
allow_failure: true
|
8
|
+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
9
|
+
when: never
|
10
|
+
- if: $CI_COMMIT_TAG
|
11
|
+
when: always
|
12
|
+
script: |
|
13
|
+
apk add git curl
|
14
|
+
GEM_VERSION="${CI_COMMIT_TAG:-$(grep VERSION lib/active_record_proxy_adapters/version.rb | tr -d 'VERSION=' | tr -d ' ' | tr -d '"')}"
|
15
|
+
mkdir ~/.gem
|
16
|
+
echo "---" > ~/.gem/credentials
|
17
|
+
echo "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/rubygems: '${CI_JOB_TOKEN}'" >> ~/.gem/credentials
|
18
|
+
chmod 0600 ~/.gem/credentials
|
19
|
+
echo "------------------"
|
20
|
+
echo "building gem"
|
21
|
+
gem build active_record_proxy_adapters.gemspec
|
22
|
+
echo "Uploading to rubygems"
|
23
|
+
curl --verbose --fail --user "$NEXUS_USER_ID:$NEXUS_PASSWORD" --upload-file "${CI_PROJECT_DIR}/active_record_proxy_adapters-${GEM_VERSION}.gem" "https://pro.nexus.aws.nasdaq.com/repository/smp-second-market-gems/active_record_proxy_adapters/"
|
data/ci/stages/test.yml
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
.test_base:
|
2
|
+
stage: test
|
3
|
+
needs:
|
4
|
+
- export
|
5
|
+
- job: postgres_primary
|
6
|
+
optional: true
|
7
|
+
- job: postgres_replica
|
8
|
+
optional: true
|
9
|
+
services:
|
10
|
+
- name: $POSTGRES_PRIMARY_IMAGE
|
11
|
+
alias: postgres-primary
|
12
|
+
variables:
|
13
|
+
POSTGRES_DB: postgres_primary_test
|
14
|
+
POSTGRES_USER: postgres_primary_test
|
15
|
+
POSTGRES_PASSWORD: postgres_primary_test
|
16
|
+
POSTGRES_HOST_AUTH_METHOD: "scram-sha-256\nhost replication all 0.0.0.0/0 md5"
|
17
|
+
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256"
|
18
|
+
- name: $POSTGRES_REPLICA_IMAGE
|
19
|
+
alias: postgres-replica
|
20
|
+
variables:
|
21
|
+
PGUSER: replicator
|
22
|
+
PGPASSWORD: replicator
|
23
|
+
PGPORT: 5433
|
24
|
+
PRIMARY_DATABASE_HOST: postgres-primary
|
25
|
+
variables:
|
26
|
+
PGHOST: postgres-primary
|
27
|
+
PG_PRIMARY_USER: postgres_primary_test
|
28
|
+
PG_PRIMARY_PASSWORD: postgres_primary_test
|
29
|
+
PG_PRIMARY_HOST: postgres-primary
|
30
|
+
PG_PRIMARY_PORT: 5432
|
31
|
+
PG_REPLICA_USER: postgres_primary_test
|
32
|
+
PG_REPLICA_PASSWORD: postgres_primary_test
|
33
|
+
PG_REPLICA_HOST: postgres-replica
|
34
|
+
PG_REPLICA_PORT: 5433
|
35
|
+
|
36
|
+
|
37
|
+
.rspec:
|
38
|
+
extends: .test_base
|
39
|
+
retry: 2
|
40
|
+
script:
|
41
|
+
- echo "Ruby version => $(ruby -v)"
|
42
|
+
- echo "ActiveRecord Version => $(gem list | grep activerecord)"
|
43
|
+
- rspec --format progress
|
44
|
+
|
45
|
+
rspec-rails-7.0.x 316 / 3:
|
46
|
+
extends: .rspec
|
47
|
+
needs:
|
48
|
+
- !reference [.test_base, needs]
|
49
|
+
- job: env-rails-7.0.x 316 / 3
|
50
|
+
optional: true
|
51
|
+
image: ${ENV_IMAGE_PREFIX}-rails7.0.0-ruby3.1.6
|
52
|
+
|
53
|
+
rspec-rails-7.0.x 325 / 3:
|
54
|
+
extends: .rspec
|
55
|
+
needs:
|
56
|
+
- !reference [.test_base, needs]
|
57
|
+
- job: env-rails-7.0.x 325 / 3
|
58
|
+
optional: true
|
59
|
+
image: ${ENV_IMAGE_PREFIX}-rails7.0.0-ruby3.2.5
|
60
|
+
|
61
|
+
rspec-rails-7.0.x 335 / 3:
|
62
|
+
extends: .rspec
|
63
|
+
needs:
|
64
|
+
- !reference [.test_base, needs]
|
65
|
+
- job: env-rails-7.0.x 335 / 3
|
66
|
+
optional: true
|
67
|
+
image: ${ENV_IMAGE_PREFIX}-rails7.0.0-ruby3.3.5
|
68
|
+
|
69
|
+
rspec-rails-7.1.x 316 / 3:
|
70
|
+
extends: .rspec
|
71
|
+
needs:
|
72
|
+
- !reference [.test_base, needs]
|
73
|
+
- job: env-rails-7.1.x 316 / 3
|
74
|
+
optional: true
|
75
|
+
image: ${ENV_IMAGE_PREFIX}-rails7.1.0-ruby3.1.6
|
76
|
+
|
77
|
+
rspec-rails-7.1.x 325 / 3:
|
78
|
+
extends: .rspec
|
79
|
+
needs:
|
80
|
+
- !reference [.test_base, needs]
|
81
|
+
- job: env-rails-7.1.x 325 / 3
|
82
|
+
optional: true
|
83
|
+
image: ${ENV_IMAGE_PREFIX}-rails7.1.0-ruby3.2.5
|
84
|
+
|
85
|
+
rspec-rails-7.1.x 335 / 3:
|
86
|
+
extends: .rspec
|
87
|
+
needs:
|
88
|
+
- !reference [.test_base, needs]
|
89
|
+
- job: env-rails-7.1.x 335 / 3
|
90
|
+
optional: true
|
91
|
+
image: ${ENV_IMAGE_PREFIX}-rails7.1.0-ruby3.3.5
|
92
|
+
|
93
|
+
rspec-rails-7.2.x 316 / 3:
|
94
|
+
extends: .rspec
|
95
|
+
needs:
|
96
|
+
- !reference [.test_base, needs]
|
97
|
+
- job: env-rails-7.2.x 316 / 3
|
98
|
+
optional: true
|
99
|
+
image: ${ENV_IMAGE_PREFIX}-rails7.2.0-ruby3.1.6
|
100
|
+
|
101
|
+
rspec-rails-7.2.x 325 / 3:
|
102
|
+
extends: .rspec
|
103
|
+
needs:
|
104
|
+
- !reference [.test_base, needs]
|
105
|
+
- job: env-rails-7.2.x 325 / 3
|
106
|
+
optional: true
|
107
|
+
image: ${ENV_IMAGE_PREFIX}-rails7.2.0-ruby3.2.5
|
108
|
+
|
109
|
+
rspec-rails-7.2.x 335 / 3:
|
110
|
+
extends: .rspec
|
111
|
+
needs:
|
112
|
+
- !reference [.test_base, needs]
|
113
|
+
- job: env-rails-7.2.x 335 / 3
|
114
|
+
optional: true
|
115
|
+
image: ${ENV_IMAGE_PREFIX}-rails7.2.0-ruby3.3.5
|
116
|
+
|
117
|
+
# Rails 8.0.x does not support Ruby 3.1.6
|
118
|
+
|
119
|
+
rspec-rails-8.0.x 325 / 3:
|
120
|
+
extends: .rspec
|
121
|
+
needs:
|
122
|
+
- !reference [.test_base, needs]
|
123
|
+
- job: env-rails-8.0.x 325 / 3
|
124
|
+
optional: true
|
125
|
+
image: ${ENV_IMAGE_PREFIX}-rails8.0.0-ruby3.2.5
|
126
|
+
|
127
|
+
rspec-rails-8.0.x 335 / 3:
|
128
|
+
extends: .rspec
|
129
|
+
needs:
|
130
|
+
- !reference [.test_base, needs]
|
131
|
+
- job: env-rails-8.0.x 335 / 3
|
132
|
+
optional: true
|
133
|
+
image: ${ENV_IMAGE_PREFIX}-rails8.0.0-ruby3.3.5
|
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
require "active_record/tasks/postgresql_proxy_database_tasks"
|
4
4
|
require "active_record/connection_adapters/postgresql_adapter"
|
5
|
-
require "active_record_proxy_adapters/
|
5
|
+
require "active_record_proxy_adapters/active_record_context"
|
6
6
|
require "active_record_proxy_adapters/hijackable"
|
7
|
+
require "active_record_proxy_adapters/postgresql_proxy"
|
7
8
|
|
8
9
|
module ActiveRecord
|
9
10
|
module ConnectionAdapters
|
@@ -14,7 +15,11 @@ module ActiveRecord
|
|
14
15
|
|
15
16
|
ADAPTER_NAME = "PostgreSQLProxy"
|
16
17
|
|
17
|
-
delegate_to_proxy :execute, :exec_query
|
18
|
+
delegate_to_proxy :execute, :exec_query
|
19
|
+
|
20
|
+
unless ActiveRecordProxyAdapters::ActiveRecordContext.active_record_v8_0_or_greater?
|
21
|
+
delegate_to_proxy :exec_no_cache, :exec_cache
|
22
|
+
end
|
18
23
|
|
19
24
|
def initialize(...)
|
20
25
|
@proxy = ActiveRecordProxyAdapters::PostgreSQLProxy.new(self)
|
@@ -29,7 +34,7 @@ module ActiveRecord
|
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
32
|
-
if ActiveRecordProxyAdapters::ActiveRecordContext.
|
37
|
+
if ActiveRecordProxyAdapters::ActiveRecordContext.active_record_v7_2_or_greater?
|
33
38
|
ActiveRecord::ConnectionAdapters.register(
|
34
39
|
"postgresql_proxy",
|
35
40
|
"ActiveRecord::ConnectionAdapters::PostgreSQLProxyAdapter",
|
@@ -4,7 +4,7 @@ module ActiveRecordProxyAdapters
|
|
4
4
|
# Collection of helpers to handle common active record methods that are defined in different places in different
|
5
5
|
# versions of rails.
|
6
6
|
class ActiveRecordContext
|
7
|
-
delegate :reading_role, :reading_role=, :writing_role, :writing_role=, to: :
|
7
|
+
delegate :reading_role, :reading_role=, :writing_role, :writing_role=, to: :ActiveRecord
|
8
8
|
delegate :legacy_connection_handling, :legacy_connection_handling=, to: :connection_handling_context
|
9
9
|
delegate :version, to: :ActiveRecord, prefix: :active_record
|
10
10
|
|
@@ -22,45 +22,27 @@ module ActiveRecordProxyAdapters
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def reading_role
|
26
|
-
role_context.reading_role
|
27
|
-
end
|
28
|
-
|
29
|
-
def writing_role
|
30
|
-
role_context.writing_role
|
31
|
-
end
|
32
|
-
|
33
25
|
def connection_class_for(connection)
|
34
|
-
|
35
|
-
|
36
|
-
klass || ActiveRecord::Base
|
26
|
+
connection.connection_class || ActiveRecord::Base
|
37
27
|
end
|
38
28
|
|
39
29
|
def connection_handling_context
|
40
30
|
# This config option has been removed in Rails 7.1+
|
41
|
-
return NullConnectionHandlingContext.new if
|
42
|
-
|
43
|
-
global_configuration_context
|
44
|
-
end
|
45
|
-
|
46
|
-
def role_context
|
47
|
-
global_configuration_context
|
48
|
-
end
|
31
|
+
return NullConnectionHandlingContext.new if active_record_v7_1_or_greater?
|
49
32
|
|
50
|
-
|
51
|
-
active_record_v6_1? ? ActiveRecord::Base : ActiveRecord
|
33
|
+
ActiveRecord
|
52
34
|
end
|
53
35
|
|
54
|
-
def
|
55
|
-
active_record_version >= Gem::Version.new("
|
36
|
+
def active_record_v7_1_or_greater?
|
37
|
+
active_record_version >= Gem::Version.new("7.1")
|
56
38
|
end
|
57
39
|
|
58
|
-
def
|
59
|
-
active_record_version >= Gem::Version.new("7.
|
40
|
+
def active_record_v7_2_or_greater?
|
41
|
+
active_record_version >= Gem::Version.new("7.2")
|
60
42
|
end
|
61
43
|
|
62
|
-
def
|
63
|
-
active_record_version >= Gem::Version.new("
|
44
|
+
def active_record_v8_0_or_greater?
|
45
|
+
active_record_version >= Gem::Version.new("8.0")
|
64
46
|
end
|
65
47
|
end
|
66
48
|
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_record_proxy_adapters/primary_replica_proxy"
|
4
|
+
require "active_record_proxy_adapters/active_record_context"
|
4
5
|
|
5
6
|
module ActiveRecordProxyAdapters
|
6
7
|
# Proxy to the original PostgreSQLAdapter, allowing the use of the ActiveRecordProxyAdapters::PrimaryReplicaProxy.
|
7
8
|
class PostgreSQLProxy < PrimaryReplicaProxy
|
8
9
|
# ActiveRecord::PostgreSQLAdapter methods that should be proxied.
|
9
|
-
hijack_method :execute, :exec_query
|
10
|
+
hijack_method :execute, :exec_query
|
11
|
+
|
12
|
+
hijack_method :exec_no_cache, :exec_cache unless ActiveRecordContext.active_record_v8_0_or_greater?
|
10
13
|
end
|
11
14
|
end
|
@@ -29,7 +29,10 @@ module ActiveRecordProxyAdapters
|
|
29
29
|
|
30
30
|
# Defines which methods should be hijacked from the original adapter and use the proxy
|
31
31
|
# @param method_names [Array<Symbol>] the list of method names from the adapter
|
32
|
-
def self.hijack_method(*method_names)
|
32
|
+
def self.hijack_method(*method_names) # rubocop:disable Metrics/MethodLength
|
33
|
+
@hijacked_methods ||= Set.new
|
34
|
+
@hijacked_methods += Set.new(method_names)
|
35
|
+
|
33
36
|
method_names.each do |method_name|
|
34
37
|
define_method(method_name) do |*args, **kwargs, &block|
|
35
38
|
proxy_bypass_method = "#{method_name}#{UNPROXIED_METHOD_SUFFIX}"
|
@@ -44,6 +47,10 @@ module ActiveRecordProxyAdapters
|
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
50
|
+
def self.hijacked_methods
|
51
|
+
@hijacked_methods.to_a
|
52
|
+
end
|
53
|
+
|
47
54
|
# @param primary_connection [ActiveRecord::ConnectionAdatpers::AbstractAdapter]
|
48
55
|
def initialize(primary_connection)
|
49
56
|
@primary_connection = primary_connection
|
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.1.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Cruz
|
@@ -16,40 +16,40 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 7.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '8.
|
22
|
+
version: '8.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 7.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '8.
|
32
|
+
version: '8.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: 7.0.0
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '8.
|
42
|
+
version: '8.1'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: 7.0.0
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '8.
|
52
|
+
version: '8.1'
|
53
53
|
description: |-
|
54
54
|
This gem allows automatic connection switching between a primary and one read replica database in ActiveRecord.
|
55
55
|
It pattern matches the SQL statement being sent to decide whether it should go to the replica (SELECT) or the
|
@@ -68,6 +68,12 @@ files:
|
|
68
68
|
- LICENSE.txt
|
69
69
|
- README.md
|
70
70
|
- Rakefile
|
71
|
+
- ci/stages/build.yml
|
72
|
+
- ci/stages/env_vars.yml
|
73
|
+
- ci/stages/lint.yml
|
74
|
+
- ci/stages/prebuild.yml
|
75
|
+
- ci/stages/push.yml
|
76
|
+
- ci/stages/test.yml
|
71
77
|
- docker-compose.yml
|
72
78
|
- lib/active_record/connection_adapters/postgresql_proxy_adapter.rb
|
73
79
|
- lib/active_record/tasks/postgresql_proxy_database_tasks.rb
|
@@ -87,10 +93,10 @@ homepage: https://github.com/Nasdaq/active_record_proxy_adapters
|
|
87
93
|
licenses:
|
88
94
|
- MIT
|
89
95
|
metadata:
|
90
|
-
allowed_push_host: https://rubygems.org
|
96
|
+
allowed_push_host: https://rubygems.org
|
91
97
|
homepage_uri: https://github.com/Nasdaq/active_record_proxy_adapters
|
92
98
|
source_code_uri: https://github.com/Nasdaq/active_record_proxy_adapters
|
93
|
-
changelog_uri: https://github.com/Nasdaq/active_record_proxy_adapters
|
99
|
+
changelog_uri: https://github.com/Nasdaq/active_record_proxy_adapters/-/blob/main/CHANGELOG.md
|
94
100
|
post_install_message:
|
95
101
|
rdoc_options: []
|
96
102
|
require_paths:
|