hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

[REFACTOR] Update Database Connection Functions for Read Operations

Open ThisIsMani opened this issue 5 months ago • 6 comments

Feature Description

Currently, in our codebase, we are using pg_connection_write for database operations even when performing read operations, which is inefficient. The pg_connection_write function should only be used when we need to perform write operations. For read operations, we should use pg_connection_read to optimize resource usage.

Possible Implementation

Find occurrences of the usage of pg_connection_write for read operations and replace them with pg_connection_read in the following files:

  • crates/router/src/db/role.rs
  • crates/router/src/db/user.rs
  • crates/router/src/db/user_role.rs
  • crates/router/src/db/dashboard_metadata.rs
  1. Open each of the specified files and search for functions that are performing read operations (for e.g., find_by_*, get_*) but are using pg_connection_write.
  2. Replace the usage of pg_connection_write with pg_connection_read in these functions.
  3. Ensure that the database calls still behave correctly and no write operations are mistakenly changed.

Have you spent some time checking if this feature request has been raised before?

  • [X] I checked and didn't find a similar issue

Submission Process:

  • Ask the maintainers for assignment of the issue, you can request for assignment by commenting on the issue itself.
  • Once assigned, submit a pull request (PR).
  • Maintainers will review and provide feedback, if any.
  • Maintainers can unassign issues due to inactivity, read more here.

Refer here for Terms and conditions for the contest.

ThisIsMani avatar Sep 19 '24 13:09 ThisIsMani