-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a database connection pool instead of mutex locking
This replaces the mutex-based PoC of 13bcbde via the `r2d2` feature of the `diesel` crate. Using `unwrap()` should be fine as `Pool::get()` only errors if the code runs into a timeout (in which case there's probably a network issue or the database is down so we could only return a proper error message instead of panicking). The `min_idle` setting defaults to `None` which causes the `max_idle` value to be used (defaults to 10). The `build()` function "will block until the pool has established its configured minimum number of connections". Therefore, it seems best to lower the value to 1 since butido is a CLI and not a service/daemon (so the pool will open additional connections on demand for the async code instead of establishing all connections at the beginning - we probably only need few database connections in most cases). Signed-off-by: Michael Weiss <[email protected]>
- Loading branch information
1 parent
35ee678
commit 1f63fc9
Showing
11 changed files
with
108 additions
and
76 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.