ockam icon indicating copy to clipboard operation
ockam copied to clipboard

Have a single `SqlxDatabase` instance per process

Open adrianbenavides opened this issue 1 year ago • 2 comments

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.

adrianbenavides avatar Jan 02 '24 13:01 adrianbenavides

@nazmulidris

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

u-na-gi avatar Feb 06 '24 02:02 u-na-gi

@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

nazmulidris avatar Feb 06 '24 02:02 nazmulidris