-
Notifications
You must be signed in to change notification settings - Fork 267
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
WIP: Adding hikari connection pool, release db connections back to pool af… #633
Conversation
…ter finished executing a statement, add hikari configuration stuff to reference.conf
This also adds a new database, called |
…es for unit tests
db { | ||
driver="org.sqlite.JDBC" | ||
mainnet { | ||
url = "jdbc:sqlite:/home/chris/.eclair/mainnet" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might cause troubles for other users than "chris". You could replace it with ~
but i'm afraid it might break the windows builds. An option is to use environment variables as specified here and use {$HOME} instead of ~
(still windows builds might be affected).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most definitely 👍 I'm going to add the WIP in tag.
…create directories when deleted
I'm not a fan of exposing the Instead you could do a jdbc-based implementation of the db traits (e.g. As for sqlite, I'm not sure whether we should leave the current implementation as-is (it is simple and don't need connection pool anyway), or if we should just use it through the standard jdbc (but it always gets messy with non-portable statements like "INSERT OR IGNORE" anyway). |
@pm47 I agree with your comment about connection pools being a implementation detail, but that is the only implementation now. I think my abstraction in From what I understand the bigger problem you have is having the |
It only works with jdbc drivers, which are blocking. Not all drivers implement
We have tried to keep the To be clear, instead of having: package db {
trait DbManagement { ... }
trait NetworkDb extends DbManagement { ... }
}
package sqlite {
class SqliteNetworkDb(override val dbConfig: NetworkDbConfig) extends NetworkDb { ... }
} I'd prefer: package db {
trait NetworkDb { ... }
}
package sqlite {
trait DbManagement { ... }
class SqliteNetworkDb extends NetworkDb with DbManagement { ... }
} With maybe |
@Christewart is that old PR still relevant? Or should we close this? |
…ter finished executing a statement, add hikari configuration stuff to reference.conf
This PR adds a connection pool to eclair so it is easier to manage database connections. I chose HikariCP as the connection pool which is used by scala slick.
There is hikari connection pool configuration stuff in the
reference.conf
file now, and we can add things later if we want to adjust our pool settings. See the home page of hikari for information about configuration. Hopefully this will also make it easier for eclair developers to use different databases than sqlite (we probably will use Postgres at SuredBits).The last thing that is different about this PR is we are now closing the statement and the connection in the
using
util method. This will release the jdbc connection back to hikari.