mirror of https://github.com/raftario/filite.git
Make connection pool size customizable
This commit is contained in:
parent
8b4eaa6e0a
commit
0aa081ed49
|
@ -503,6 +503,7 @@ dependencies = [
|
|||
"diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libsqlite3-sys 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -7,6 +7,7 @@ edition = "2018"
|
|||
[dependencies]
|
||||
actix-web = "1.0.8"
|
||||
chrono = "0.4.9"
|
||||
num_cpus = "1.10.1"
|
||||
[dependencies.diesel]
|
||||
version = "1.4.2"
|
||||
features = ["r2d2", "sqlite"]
|
||||
|
|
|
@ -19,9 +19,10 @@ pub mod setup {
|
|||
use diesel::sqlite::SqliteConnection;
|
||||
|
||||
/// Creates a SQLite database connection pool
|
||||
pub fn create_pool(url: &str) -> Pool {
|
||||
pub fn create_pool(url: &str, size: u32) -> Pool {
|
||||
let manager = ConnectionManager::<SqliteConnection>::new(url);
|
||||
r2d2::Pool::builder()
|
||||
.max_size(size)
|
||||
.build(manager)
|
||||
.expect("Can't create pool.")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue