refactor(users): Update Database connection for Read only functions
Type of Change
- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [x] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
This PR refactors the database connection logic by changing the function from pg_connection_write() to pg_connection_read() for functions that only perform read operations from the database. This is an internal change aimed at optimizing resource usage. All user-facing APIs should continue to function as expected without any disruptions.
Additional Changes
- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables
Motivation and Context
This change is required to improve efficiency by ensuring that we use the appropriate connection type for read operations. It resolves the inefficiency of using write connections for read-only database queries.
- Fixes https://github.com/juspay/hyperswitch/issues/5965
How did you test it?
- Verified that all user-related APIs are working without any issues.
- All existing test cases for database read and write operations passed successfully.
- Confirmed that this internal change does not affect the functionality of user-facing APIs.
Checklist
- [x] I formatted the code
cargo +nightly fmt --all - [ ] I addressed lints thrown by
cargo clippy - [x] I reviewed the submitted code
- [x] I added unit tests for my changes where possible
Review changes with SemanticDiff.
Analyzed 4 of 4 files.
| Filename | Status | |
|---|---|---|
| :heavy_check_mark: | crates/router/src/db/dashboard_metadata.rs | Analyzed |
| :heavy_check_mark: | crates/router/src/db/role.rs | Analyzed |
| :heavy_check_mark: | crates/router/src/db/user.rs | Analyzed |
| :heavy_check_mark: | crates/router/src/db/user_role.rs | Analyzed |
Please add something in description saying that this is a internal change and all the user related APIs should work without any issues in the testcases section.
Please add something in description saying that this is a internal change and all the user related APIs should work without any issues in the testcases section.
Done @ThisIsMani , I apologize for any beginner mistakes I made while raising this PR. Thank you for your patience and support
Hey @zeel991, can you check the original template and change you PR description into that template.
Hey @zeel991, can you check the original template and change you PR description into that template.
Are these changes appropriate ?
Yeah, looks fine.
Hello @ThisIsMani ,would you please consider adding the hactoberfest tag to the PR
Hey @ThisIsMani , since this PR is approved, when can it be merged ?
@zeel991, will get this merged by Monday.
Hey @zeel991, can you resolve the conflicts.
Hey @zeel991, can you resolve the conflicts.
Done ! 👍🏻
Hello @ThisIsMani , I am Zeel Darji , C4GT community Lead and Open source Lead of Development Wing of IIITN . I am organizing an open source event in my college's techfest which higlights the importance of DPGs and DPIs .
I wanted to ask you if participants could contribute to the repos of Juspay for our Event ?
Hey @zeel991, Happy to help with the event. Pinged you in community workspace, we can continue the discussion there.
Hey @zeel991, Happy to help with the event. Pinged you in community workspace, we can continue the discussion there.
Can you please send the link , I couldn't find it
Hey @zeel991, Happy to help with the event. Pinged you in community workspace, we can continue the discussion there.
Can you please send the link , I couldn't find it
Please check Hyperswitch Slack workspace
@ThisIsMani Should I update the branch ?
@ThisIsMani Should I update the branch ?
Not needed.
But seems like formatting check if failing in the PR, can you format the code using just fmt and push the changes.
But seems like formatting check if failing in the PR, can you format the code using
just fmtand push the changes.
I have removed the merge conflict and formatted the PR
Hey @ThisIsMani If my contribution is as required , can you please merge my PR , as I have been getting conflicts
@ThisIsMani All the tests have passed
Hey @zeel991, your PR has been approved, It will take some time for it to be merged, Kindly check in after 15th October