Skip to content
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

Add database_role option to scope checks for replicas #57

Merged
merged 4 commits into from
Dec 13, 2023

Conversation

geoffharcourt
Copy link
Contributor

@geoffharcourt geoffharcourt commented Nov 3, 2023

It can be useful to confirm that certain database queries are being
made against a primary database or a replica database. This change
adds a new option database_role, which makes the query counter only
count queries that were made against a database with the specified
role.

We've used this logic at CommonLit for several years to ensure we're
querying the right database. This works in test environments even if
your primary and replica database configurations point at the same
database.

This is a retry at the work in #51. CI is failing on Rails Edge, but
it doesn't look related to the changes as far as I can tell.

@geoffharcourt geoffharcourt force-pushed the gh-using-follower branch 2 times, most recently from 53f6031 to fb02238 Compare November 3, 2023 01:55
It can be useful to confirm that certain database queries are being made
against a primary database or a replica database. This change adds a new
option `database_role`, which makes the query counter only count queries
that were made against a database with the specified role.

We've used this logic at CommonLit for several years to ensure we're
querying the right database. This works in test environments even if
your primary and replica database configurations point at the same
database.
@sds sds merged commit 13a3283 into sds:main Dec 13, 2023
19 of 20 checks passed
@geoffharcourt
Copy link
Contributor Author

@sds thanks for the review and merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants