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

feat: Add support for replicas and cross region replicas #3300

Merged
merged 21 commits into from
Feb 9, 2024

Conversation

zachaysan
Copy link
Contributor

@zachaysan zachaysan commented Jan 16, 2024

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Support fallbacking from replicas that go down and support multiple replica options. See this ticket's comment for full details.

How did you test this code?

I hard coded a single default database. Extensive testing by hand to make sure the caches and connections worked, then later I introduced one test that verifies the connection works against the default database and in addition to that I added in several tests against the router logic with mocked logic to mimic database connection issues.

Copy link

vercel bot commented Jan 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 9, 2024 3:21pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 9, 2024 3:21pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 9, 2024 3:21pm

Copy link
Contributor

github-actions bot commented Jan 16, 2024

Uffizzi Preview deployment-44448 was deleted.

@codecov-commenter
Copy link

codecov-commenter commented Jan 16, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (da178a8) 95.94% compared to head (01a2a70) 95.94%.
Report is 1 commits behind head on main.

Files Patch % Lines
api/app/routers.py 87.75% 6 Missing ⚠️
api/app/settings/common.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3300      +/-   ##
==========================================
- Coverage   95.94%   95.94%   -0.01%     
==========================================
  Files        1077     1079       +2     
  Lines       33021    33149     +128     
==========================================
+ Hits        31682    31804     +122     
- Misses       1339     1345       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zachaysan zachaysan requested a review from khvn26 January 16, 2024 19:21
@dabeeeenster dabeeeenster changed the title WIP feat: Add support for replicas and cross region replicas feat: (WIP) Add support for replicas and cross region replicas Jan 16, 2024
@zachaysan zachaysan changed the title feat: (WIP) Add support for replicas and cross region replicas feat: Add support for replicas and cross region replicas Jan 17, 2024
@zachaysan zachaysan marked this pull request as ready for review January 17, 2024 15:45
api/app/routers.py Show resolved Hide resolved
api/app/routers.py Outdated Show resolved Hide resolved
api/app/settings/common.py Outdated Show resolved Hide resolved
api/tests/unit/app/test_unit_app_routers.py Outdated Show resolved Hide resolved
Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with one extremely minor comment.

Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also approved with 2 minor comments.

Comment on lines 9 to 10
logger = logging.getLogger(__name__)
CONNECTION_CHECK_CACHE_TTL = 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: imo these should be separated by a (blank) new line whitespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks fine my way, but I don't mind doing it your way either so I've updated it.

Comment on lines 18 to 19
class ImproperlyConfiguredError(RuntimeError):
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love that this exception isn't defined in an exceptions module, but perhaps it's overkill if app.exceptions doesn't already exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to move it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API docs Documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants