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

Have a single SqlxDatabase instance per process #7313

Open
adrianbenavides opened this issue Jan 2, 2024 · 2 comments
Open

Have a single SqlxDatabase instance per process #7313

adrianbenavides opened this issue Jan 2, 2024 · 2 comments
Assignees

Comments

@adrianbenavides
Copy link
Member

Current behavior

There are some places where we are creating multiple SqlxDatabase instances, like here.

Desired behavior

The SqlxDatabse struct should be created once per db file/process (we currently have only one db file).

One way to achieve this would be to add a OnceLock inside the SqlxDatabase struct so that it gets initialized only once in the create function.

Another approach would be to investigate how can we refactor the creation of the database instance so it's just created once. That would mean detecting all the places where we are creating the database object multiple times and refactoring them accordingly.

@u-na-gi
Copy link

u-na-gi commented Feb 6, 2024

@nazmulidris

I want to try this issue.
Would it be possible for you to assign this to me?

@nazmulidris
Copy link
Contributor

@u-na-gi That's awesome, this is all yours. Please let us know if you have any questions as you explore. You can also ask questions on the contributors discord https://discord.ockam.io

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

No branches or pull requests

3 participants