-
Notifications
You must be signed in to change notification settings - Fork 166
Use ActiveRecord configuration to read from replica for reporting #5272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
6d828d2
64636d6
f806ecc
4cfdf14
ba3da14
40250fa
ffe7ec8
f313c7e
7017830
216b3e9
27926b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| class ApplicationRecord < ActiveRecord::Base | ||
| self.abstract_class = true | ||
|
|
||
| connects_to shards: { | ||
| default: { writing: :primary, reading: :primary }, | ||
| read_replica: { reading: :primary_replica }, | ||
| } | ||
| end |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| <% require 'production_database_configuration' %> | ||
|
|
||
| postgresql: &postgresql | ||
| adapter: postgresql | ||
| encoding: utf8 | ||
|
|
@@ -24,22 +22,44 @@ defaults: &defaults | |
| statement_timeout: <%= IdentityConfig.store.database_statement_timeout %> | ||
|
|
||
| development: | ||
| <<: *defaults | ||
| primary: | ||
| <<: *defaults | ||
| primary_replica: | ||
| <<: *defaults | ||
| replica: true | ||
|
|
||
| test: | ||
| _test: &test | ||
| <<: *defaults | ||
| pool: 10 | ||
| checkout_timeout: 10 | ||
| database: <%= ENV['POSTGRES_DB'] || "upaya_test#{ENV['TEST_ENV_NUMBER']}" %> | ||
| user: <%= ENV['POSTGRES_USER'] %> | ||
| password: <%= ENV['POSTGRES_PASSWORD'] %> | ||
|
|
||
| test: | ||
| primary: | ||
| <<: *test | ||
| primary_replica: | ||
| <<: *test | ||
| replica: true | ||
|
|
||
| production: | ||
| <<: *defaults | ||
| database: <%= IdentityConfig.store.database_name %> | ||
| username: <%= ProductionDatabaseConfiguration.username %> | ||
| host: <%= ProductionDatabaseConfiguration.host %> | ||
| password: <%= ProductionDatabaseConfiguration.password %> | ||
| pool: <%= ProductionDatabaseConfiguration.pool %> | ||
| sslmode: 'verify-full' | ||
| sslrootcert: '/usr/local/share/aws/rds-combined-ca-bundle.pem' | ||
| primary: | ||
| <<: *defaults | ||
| database: <%= IdentityConfig.store.database_name %> | ||
| username: <%= IdentityConfig.store.database_username %> | ||
| host: <%= IdentityConfig.store.database_host %> | ||
| password: <%= IdentityConfig.store.database_password %> | ||
| pool: <%= IdentityConfig.store.database_pool_idp %> | ||
| sslmode: 'verify-full' | ||
| sslrootcert: '/usr/local/share/aws/rds-combined-ca-bundle.pem' | ||
| primary_replica: | ||
| <<: *defaults | ||
| database: <%= IdentityConfig.store.database_name %> | ||
| username: <%= IdentityConfig.store.database_readonly_username %> | ||
| host: <%= IdentityConfig.store.database_read_replica_host %> | ||
| password: <%= IdentityConfig.store.database_readonly_password %> | ||
| pool: <%= IdentityConfig.store.database_pool_idp %> | ||
| sslmode: 'verify-full' | ||
| sslrootcert: '/usr/local/share/aws/rds-combined-ca-bundle.pem' | ||
| replica: true | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. turns out when a connection is set to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh sweet that's awesome |
||
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: should we call it
read_replicainstead? That threw me off a little bit when you callestablish_connection.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, and that matches the name in devops repo where we call it
read-replica, updated in 27926b2