active_record_proxy_adapters 0.3.2 → 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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +4 -0
  3. data/.rubocop.yml +18 -0
  4. data/Appraisals +25 -0
  5. data/CHANGELOG.md +49 -0
  6. data/CODE_OF_CONDUCT.md +132 -0
  7. data/Dockerfile +21 -0
  8. data/db/mysql_structure.sql +41 -0
  9. data/db/postgresql_structure.sql +86 -0
  10. data/docker/postgres_replica/cmd.sh +9 -0
  11. data/docker-compose.yml +98 -0
  12. data/gemfiles/rails_7.0.gemfile +25 -0
  13. data/gemfiles/rails_7.0.gemfile.lock +122 -0
  14. data/gemfiles/rails_7.1.gemfile +21 -0
  15. data/gemfiles/rails_7.1.gemfile.lock +131 -0
  16. data/gemfiles/rails_7.2.gemfile +21 -0
  17. data/gemfiles/rails_7.2.gemfile.lock +129 -0
  18. data/gemfiles/rails_8.0.gemfile +21 -0
  19. data/gemfiles/rails_8.0.gemfile.lock +131 -0
  20. data/lib/active_record/connection_adapters/mysql2_proxy_adapter.rb +2 -0
  21. data/lib/active_record/connection_adapters/postgresql_proxy_adapter.rb +3 -0
  22. data/lib/active_record/connection_adapters/trilogy_proxy_adapter.rb +41 -0
  23. data/lib/active_record/tasks/trilogy_proxy_database_tasks.rb +19 -0
  24. data/lib/active_record_proxy_adapters/connection_handling/mysql2.rb +29 -23
  25. data/lib/active_record_proxy_adapters/connection_handling/postgresql.rb +27 -21
  26. data/lib/active_record_proxy_adapters/connection_handling/trilogy.rb +44 -0
  27. data/lib/active_record_proxy_adapters/connection_handling.rb +1 -7
  28. data/lib/active_record_proxy_adapters/railtie.rb +1 -4
  29. data/lib/active_record_proxy_adapters/trilogy_proxy.rb +9 -0
  30. data/lib/active_record_proxy_adapters/version.rb +1 -1
  31. data/postgres_primary.dockerfile +34 -0
  32. data/postgres_replica.dockerfile +15 -0
  33. data/sig/active_record_proxy_adapters.rbs +4 -0
  34. metadata +27 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2af4688cfe39f70ecd6e984f379b9af4a0bc72970e753393fc23d491b0471a35
4
- data.tar.gz: e18681c7b4ed95185bdfa2bd36121c438b113d592223b8cf3838848e530dfd7a
3
+ metadata.gz: 6ccf5136620d4473a468a5749886cb74d4a585b6d9b9f3f77c451715a16d9384
4
+ data.tar.gz: a75b44a62192b0cff1741170c9acff251fd19348f3651ff1750446bf8d459596
5
5
  SHA512:
6
- metadata.gz: 6e0b74329b3de7b75b990fb80ce09b848e605f43b0adbb91f21eed1f01009849f0de2fe8184a21736f5b4515a2f0b71c1a5287fe81aa0e0a189f07dd789dac9e
7
- data.tar.gz: 17ff6ee897897fdcbb3b0d2c16bf1c17cd84f6168cb0015ed3c17de90796fb988e82995835f82585d026db0f842cd020fcfe5d2c5c05c70606ff00407742b0bc
6
+ metadata.gz: 9b37879abd9fd61b31bf50d450f50d0721be6251a8da0402732f3dbff1c5e486d728422581e3d95a8c5f4e762ac0a8b2ba364863e84728b3c0f5a5d54fe9eb5e
7
+ data.tar.gz: 553d0c18c4274aab856c3a8f6bcc110d41babd290fe1397ec07f5abfcde810d6b22e734afd33a7035c072f1f5d2b9e1a6f6fd1d29ce19f5bd9b1b89e967f3803
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format documentation
2
+ --color
3
+ --order random
4
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 3.1
6
+ NewCops: enable
7
+ Exclude:
8
+ - 'gemfiles/**/*'
9
+
10
+ Style/StringLiterals:
11
+ EnforcedStyle: double_quotes
12
+
13
+ Style/StringLiteralsInInterpolation:
14
+ EnforcedStyle: double_quotes
15
+
16
+ RSpec/NestedGroups:
17
+ Enabled: true
18
+ Max: 5
data/Appraisals ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise "rails-7.0" do
4
+ gem "activerecord", "~> 7.0.0"
5
+ gem "activesupport", "~> 7.0.0"
6
+ gem "concurrent-ruby", "1.3.4"
7
+ gem "mutex_m"
8
+ gem "bigdecimal"
9
+ gem "activerecord-trilogy-adapter"
10
+ end
11
+
12
+ appraise "rails-7.1" do
13
+ gem "activerecord", "~> 7.1.0"
14
+ gem "activesupport", "~> 7.1.0"
15
+ end
16
+
17
+ appraise "rails-7.2" do
18
+ gem "activerecord", "~> 7.2.0"
19
+ gem "activesupport", "~> 7.2.0"
20
+ end
21
+
22
+ appraise "rails-8.0" do
23
+ gem "activerecord", "~> 8.0.0"
24
+ gem "activesupport", "~> 8.0.0"
25
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,49 @@
1
+ ## [Unreleased]
2
+
3
+ - Add load hooks for proxy adapters
4
+ - Add TrilogyProxyAdapter
5
+
6
+ ## [0.3.1] - 2025-02-12
7
+ - Fix Active Record adapters dependency loading https://github.com/Nasdaq/active_record_proxy_adapters/commit/b729f8bdb517cdc80f348c00e1fe4c5b56b76143
8
+
9
+ ## [0.3.0] - 2025-01-17
10
+
11
+ - Add Mysql2ProxyAdapter https://github.com/Nasdaq/active_record_proxy_adapters/commit/7481b79dc93114f9b3b40faa8f3eecce90fe9104
12
+
13
+ ## [0.2.2, 0.1.5] - 2025-01-02
14
+
15
+ - Handle PendingMigrationConnection introduced by Rails 7.2 and backported to Rails 7.1 https://github.com/Nasdaq/active_record_proxy_adapters/commit/793562694c05d554bad6e14637b34e5f9ffd2fc5
16
+ - Stick to same connection throughout request span https://github.com/Nasdaq/active_record_proxy_adapters/commit/789742fd7a33ecd555a995e8a1e1336455caec75
17
+
18
+ ## [0.2.1] - 2025-01-02
19
+
20
+ - Fix replica connection pool getter when specific connection name is not found https://github.com/Nasdaq/active_record_proxy_adapters/commit/847e150dd21c5bc619745ee1d9d8fcaa9b8f2eea
21
+
22
+ ## [0.2.0] - 2024-12-24
23
+
24
+ - Add custom log subscriber to tag queries based on the adapter being used https://github.com/Nasdaq/active_record_proxy_adapters/commit/68b8c1f4191388eb957bf12e0f84289da667e940
25
+
26
+ ## [0.1.4] - 2025-01-02
27
+
28
+ - Fix replica connection pool getter when specific connection name is not found https://github.com/Nasdaq/active_record_proxy_adapters/commit/88b32a282b54d420e652f638656dbcf063ac8796
29
+
30
+ ## [0.1.3] - 2024-12-24
31
+
32
+ - Fix replica connection pool getter when database configurations have multiple replicas https://github.com/Nasdaq/active_record_proxy_adapters/commit/ea5a33997da45ac073f166b3fbd2d12426053cd6
33
+ - Retrieve replica pool without checking out a connection https://github.com/Nasdaq/active_record_proxy_adapters/commit/6470ef58e851082ae1f7a860ecdb5b451ef903c8
34
+
35
+ ## [0.1.2] - 2024-12-16
36
+
37
+ - Fix CTE regex matcher https://github.com/Nasdaq/active_record_proxy_adapters/commit/4b1d10bfd952fb1f5b102de8cc1a5bd05d25f5e9
38
+
39
+ ## [0.1.1] - 2024-11-27
40
+
41
+ - Enable RubyGems MFA https://github.com/Nasdaq/active_record_proxy_adapters/commit/2a71b1f4354fb966cc0aa68231ca5837814e07ee
42
+
43
+ ## [0.1.0] - 2024-11-19
44
+
45
+ - Add PostgreSQLProxyAdapter https://github.com/Nasdaq/active_record_proxy_adapters/commit/2b3bb9f7359139519b32af3018ceb07fed8c6b33
46
+
47
+ ## [0.1.0.rc2] - 2024-10-28
48
+
49
+ - Add PostgreSQLProxyAdapter https://github.com/Nasdaq/active_record_proxy_adapters/commit/2b3bb9f7359139519b32af3018ceb07fed8c6b33
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/Dockerfile ADDED
@@ -0,0 +1,21 @@
1
+ ARG RUBY_VERSION=3.2.3
2
+ ARG DOCKER_REGISTRY=docker.io
3
+ FROM $DOCKER_REGISTRY/ruby:$RUBY_VERSION-alpine
4
+ ENV RAILS_VERSION="8.0.0"
5
+ ENV RAILS_ENV=test
6
+
7
+ RUN apk --update add \
8
+ build-base \
9
+ git \
10
+ postgresql-dev \
11
+ postgresql17-client \
12
+ mariadb-client \
13
+ mariadb-dev
14
+ RUN gem install bundler -v 2.5.13
15
+
16
+ COPY . /app
17
+ WORKDIR /app
18
+
19
+ RUN bundle install
20
+ RUN bundle exec appraisal install
21
+
@@ -0,0 +1,41 @@
1
+ /*M!999999\- enable the sandbox mode */
2
+
3
+ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
4
+ /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
5
+ /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
6
+ /*!40101 SET NAMES utf8mb4 */;
7
+ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
8
+ /*!40103 SET TIME_ZONE='+00:00' */;
9
+ /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
10
+ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
11
+ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
12
+ /*M!100616 SET @OLD_NOTE_VERBOSITY=@@NOTE_VERBOSITY, NOTE_VERBOSITY=0 */;
13
+ DROP TABLE IF EXISTS `schema_migrations`;
14
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
15
+ /*!40101 SET character_set_client = utf8 */;
16
+ CREATE TABLE `schema_migrations` (
17
+ `version` varchar(255) NOT NULL
18
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
19
+ /*!40101 SET character_set_client = @saved_cs_client */;
20
+ DROP TABLE IF EXISTS `users`;
21
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
22
+ /*!40101 SET character_set_client = utf8 */;
23
+ CREATE TABLE `users` (
24
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
25
+ `name` text NOT NULL,
26
+ `email` text NOT NULL,
27
+ `created_at` timestamp NULL DEFAULT current_timestamp(),
28
+ `updated_at` timestamp NULL DEFAULT current_timestamp(),
29
+ PRIMARY KEY (`id`)
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
31
+ /*!40101 SET character_set_client = @saved_cs_client */;
32
+ /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
33
+
34
+ /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
35
+ /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
36
+ /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
37
+ /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
38
+ /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
39
+ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
40
+ /*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */;
41
+
@@ -0,0 +1,86 @@
1
+ SET statement_timeout = 0;
2
+ SET lock_timeout = 0;
3
+ SET idle_in_transaction_session_timeout = 0;
4
+ SET transaction_timeout = 0;
5
+ SET client_encoding = 'UTF8';
6
+ SET standard_conforming_strings = on;
7
+ SELECT pg_catalog.set_config('search_path', '', false);
8
+ SET check_function_bodies = false;
9
+ SET xmloption = content;
10
+ SET client_min_messages = warning;
11
+ SET row_security = off;
12
+
13
+ SET default_tablespace = '';
14
+
15
+ SET default_table_access_method = heap;
16
+
17
+ --
18
+ -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
19
+ --
20
+
21
+ CREATE TABLE public.schema_migrations (
22
+ version character varying(255) NOT NULL
23
+ );
24
+
25
+
26
+ --
27
+ -- Name: users; Type: TABLE; Schema: public; Owner: -
28
+ --
29
+
30
+ CREATE TABLE public.users (
31
+ id integer NOT NULL,
32
+ name text NOT NULL,
33
+ email text NOT NULL,
34
+ created_at timestamp without time zone DEFAULT now() NOT NULL,
35
+ updated_at timestamp without time zone DEFAULT now() NOT NULL
36
+ );
37
+
38
+
39
+ --
40
+ -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
41
+ --
42
+
43
+ CREATE SEQUENCE public.users_id_seq
44
+ AS integer
45
+ START WITH 1
46
+ INCREMENT BY 1
47
+ NO MINVALUE
48
+ NO MAXVALUE
49
+ CACHE 1;
50
+
51
+
52
+ --
53
+ -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
54
+ --
55
+
56
+ ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
57
+
58
+
59
+ --
60
+ -- Name: users id; Type: DEFAULT; Schema: public; Owner: -
61
+ --
62
+
63
+ ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
64
+
65
+
66
+ --
67
+ -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
68
+ --
69
+
70
+ ALTER TABLE ONLY public.users
71
+ ADD CONSTRAINT users_pkey PRIMARY KEY (id);
72
+
73
+
74
+ --
75
+ -- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -
76
+ --
77
+
78
+ CREATE UNIQUE INDEX unique_schema_migrations ON public.schema_migrations USING btree (version);
79
+
80
+
81
+ --
82
+ -- PostgreSQL database dump complete
83
+ --
84
+
85
+ SET search_path TO "$user", public;
86
+
@@ -0,0 +1,9 @@
1
+ until pg_basebackup --pgdata=/var/lib/postgresql/data -R --slot=$PRIMARY_REPLICATION_SLOT --host=$PRIMARY_DATABASE_HOST --port=$PRIMARY_DATABASE_PORT
2
+ do
3
+ echo 'Waiting for primary to connect...'
4
+ sleep 1s
5
+ done
6
+
7
+ echo 'Backup done, starting replica...'
8
+ chmod 0700 /var/lib/postgresql/data
9
+ postgres
@@ -0,0 +1,98 @@
1
+ name: active_record_proxy_adapters
2
+
3
+ x-postgres-common: &postgres-common
4
+ restart: always
5
+ user: postgres
6
+ healthcheck:
7
+ test: 'pg_isready -U postgres_primary_test --dbname=postgres'
8
+ interval: 10s
9
+ timeout: 5s
10
+ retries: 5
11
+ networks:
12
+ - postgres
13
+
14
+ services:
15
+ app:
16
+ build:
17
+ args:
18
+ - RUBY_VERSION=${RUBY_VERSION:-3.3.6}
19
+ container_name: app
20
+ image: active_record_proxy_adapters-app:${ENV_TAG:-latest}
21
+ tty: true
22
+ stdin_open: true
23
+ environment:
24
+ - RAILS_VERSION=${RAILS_VERSION:-8.0.0}
25
+ - PGHOST=postgres_primary
26
+ - PG_PRIMARY_USER=postgres_primary_test
27
+ - PG_PRIMARY_PASSWORD=postgres_primary_test
28
+ - PG_PRIMARY_HOST=postgres_primary
29
+ - PG_PRIMARY_PORT=5432
30
+ - PG_REPLICA_USER=postgres_primary_test
31
+ - PG_REPLICA_PASSWORD=postgres_primary_test
32
+ - PG_REPLICA_HOST=postgres_replica
33
+ - PG_REPLICA_PORT=5432
34
+ - MYSQL_PRIMARY_USER=root
35
+ - MYSQL_PRIMARY_PASSWORD=mysql
36
+ - MYSQL_PRIMARY_HOST=mysql_primary
37
+ - MYSQL_PRIMARY_PORT=3306
38
+ - MYSQL_REPLICA_USER=root
39
+ - MYSQL_REPLICA_PASSWORD=mysql
40
+ - MYSQL_REPLICA_HOST=mysql_primary
41
+ - MYSQL_REPLICA_PORT=3306
42
+ depends_on:
43
+ - postgres_primary
44
+ - postgres_replica
45
+ - mariadb
46
+ networks:
47
+ - app
48
+ - postgres
49
+ - mariadb
50
+ volumes:
51
+ - .:/app
52
+ postgres_primary:
53
+ <<: *postgres-common
54
+ build:
55
+ context: .
56
+ dockerfile: postgres_primary.dockerfile
57
+ args:
58
+ - POSTGRES_LOGGING_COLLECTOR=${POSTGRES_LOGGING_COLLECTOR:-}
59
+ - POSTGRES_LOG_DESTINATION=${POSTGRES_LOG_DESTINATION:-}
60
+ - POSTGRES_LOG_STATEMENT=${POSTGRES_LOG_STATEMENT:-}
61
+ - REPLICA_USER=replicator
62
+ - REPLICA_PASSWORD=replicator
63
+ container_name: postgres_primary
64
+ environment:
65
+ POSTGRES_DB: postgres
66
+ POSTGRES_USER: postgres_primary_test
67
+ POSTGRES_PASSWORD: postgres_primary_test
68
+ POSTGRES_HOST_AUTH_METHOD: "scram-sha-256\nhost replication all 0.0.0.0/0 md5"
69
+ POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256"
70
+
71
+ postgres_replica:
72
+ <<: *postgres-common
73
+ build:
74
+ context: .
75
+ dockerfile: postgres_replica.dockerfile
76
+ container_name: postgres_replica
77
+ environment:
78
+ PGUSER: replicator
79
+ PGPASSWORD: replicator
80
+ PRIMARY_DATABASE_HOST: postgres_primary
81
+ depends_on:
82
+ - postgres_primary
83
+ # TODO: create mysql replica images
84
+ mariadb:
85
+ image: mariadb:11.4
86
+ container_name: mysql_primary
87
+ environment:
88
+ MARIADB_ROOT_PASSWORD: mysql
89
+ MARIADB_DATABASE: mysql
90
+ ports:
91
+ - "3306:3306"
92
+ networks:
93
+ - mariadb
94
+
95
+ networks:
96
+ app:
97
+ postgres:
98
+ mariadb:
@@ -0,0 +1,25 @@
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.0.0"
11
+ gem "activesupport", "~> 7.0.0"
12
+ gem "concurrent-ruby", "1.3.4"
13
+ gem "mutex_m"
14
+ gem "bigdecimal"
15
+ gem "activerecord-trilogy-adapter"
16
+
17
+ group :test do
18
+ gem "rspec", "~> 3.0"
19
+ gem "rubocop", "~> 1.72"
20
+ gem "rubocop-rspec", "~> 3.5.0"
21
+ gem "simplecov"
22
+ gem "simplecov-cobertura"
23
+ end
24
+
25
+ gemspec path: "../"
@@ -0,0 +1,122 @@
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.0.8.7)
12
+ activesupport (= 7.0.8.7)
13
+ activerecord (7.0.8.7)
14
+ activemodel (= 7.0.8.7)
15
+ activesupport (= 7.0.8.7)
16
+ activerecord-trilogy-adapter (3.1.2)
17
+ activerecord (>= 6.0.a, < 7.1.a)
18
+ trilogy (>= 2.4.0)
19
+ activesupport (7.0.8.7)
20
+ concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ i18n (>= 1.6, < 2)
22
+ minitest (>= 5.1)
23
+ tzinfo (~> 2.0)
24
+ appraisal (2.5.0)
25
+ bundler
26
+ rake
27
+ thor (>= 0.14.0)
28
+ ast (2.4.2)
29
+ bigdecimal (3.1.9)
30
+ concurrent-ruby (1.3.4)
31
+ diff-lcs (1.6.0)
32
+ docile (1.4.1)
33
+ i18n (1.14.7)
34
+ concurrent-ruby (~> 1.0)
35
+ json (2.10.1)
36
+ language_server-protocol (3.17.0.4)
37
+ lint_roller (1.1.0)
38
+ minitest (5.25.4)
39
+ mutex_m (0.3.0)
40
+ mysql2 (0.5.6)
41
+ parallel (1.26.3)
42
+ parser (3.3.7.1)
43
+ ast (~> 2.4.1)
44
+ racc
45
+ pg (1.5.9)
46
+ racc (1.8.1)
47
+ rainbow (3.1.1)
48
+ rake (13.2.1)
49
+ regexp_parser (2.10.0)
50
+ rexml (3.4.0)
51
+ rspec (3.13.0)
52
+ rspec-core (~> 3.13.0)
53
+ rspec-expectations (~> 3.13.0)
54
+ rspec-mocks (~> 3.13.0)
55
+ rspec-core (3.13.3)
56
+ rspec-support (~> 3.13.0)
57
+ rspec-expectations (3.13.3)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.13.0)
60
+ rspec-mocks (3.13.2)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.13.0)
63
+ rspec-support (3.13.2)
64
+ rubocop (1.72.2)
65
+ json (~> 2.3)
66
+ language_server-protocol (~> 3.17.0.2)
67
+ lint_roller (~> 1.1.0)
68
+ parallel (~> 1.10)
69
+ parser (>= 3.3.0.2)
70
+ rainbow (>= 2.2.2, < 4.0)
71
+ regexp_parser (>= 2.9.3, < 3.0)
72
+ rubocop-ast (>= 1.38.0, < 2.0)
73
+ ruby-progressbar (~> 1.7)
74
+ unicode-display_width (>= 2.4.0, < 4.0)
75
+ rubocop-ast (1.38.0)
76
+ parser (>= 3.3.1.0)
77
+ rubocop-rspec (3.5.0)
78
+ lint_roller (~> 1.1)
79
+ rubocop (~> 1.72, >= 1.72.1)
80
+ ruby-progressbar (1.13.0)
81
+ simplecov (0.22.0)
82
+ docile (~> 1.1)
83
+ simplecov-html (~> 0.11)
84
+ simplecov_json_formatter (~> 0.1)
85
+ simplecov-cobertura (2.1.0)
86
+ rexml
87
+ simplecov (~> 0.19)
88
+ simplecov-html (0.13.1)
89
+ simplecov_json_formatter (0.1.4)
90
+ thor (1.3.2)
91
+ trilogy (2.9.0)
92
+ tzinfo (2.0.6)
93
+ concurrent-ruby (~> 1.0)
94
+ unicode-display_width (3.1.4)
95
+ unicode-emoji (~> 4.0, >= 4.0.4)
96
+ unicode-emoji (4.0.4)
97
+
98
+ PLATFORMS
99
+ aarch64-linux-musl
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ active_record_proxy_adapters!
104
+ activerecord (~> 7.0.0)
105
+ activerecord-trilogy-adapter
106
+ activesupport (~> 7.0.0)
107
+ appraisal
108
+ bigdecimal
109
+ concurrent-ruby (= 1.3.4)
110
+ mutex_m
111
+ mysql2 (~> 0.5)
112
+ pg (~> 1.5)
113
+ rake (~> 13.0)
114
+ rspec (~> 3.0)
115
+ rubocop (~> 1.72)
116
+ rubocop-rspec (~> 3.5.0)
117
+ simplecov
118
+ simplecov-cobertura
119
+ trilogy (~> 2.9)
120
+
121
+ BUNDLED WITH
122
+ 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.1.0"
11
+ gem "activesupport", "~> 7.1.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: "../"