diff options
author | Alex Auvolat <alex@adnab.me> | 2024-03-18 17:08:54 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2024-03-18 18:05:25 +0100 |
commit | e8f9718ccd656dacc4fba2ed9fa5d8abf12ad37b (patch) | |
tree | 8896fd504d6fc1be97324c1d813309a24bf43e82 /src/db/open.rs | |
parent | fd2e19bf1bf301bc03aa29ffa3fe1e71008cbe50 (diff) | |
download | garage-e8f9718ccd656dacc4fba2ed9fa5d8abf12ad37b.tar.gz garage-e8f9718ccd656dacc4fba2ed9fa5d8abf12ad37b.zip |
[sqlite-r2d2] implement connection pooling in sqlite backend
Diffstat (limited to 'src/db/open.rs')
-rw-r--r-- | src/db/open.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/db/open.rs b/src/db/open.rs index ae135c4e..59d06f2e 100644 --- a/src/db/open.rs +++ b/src/db/open.rs @@ -91,14 +91,8 @@ pub fn open_db(path: &PathBuf, engine: Engine, opt: &OpenOpt) -> Result<Db> { #[cfg(feature = "sqlite")] Engine::Sqlite => { info!("Opening Sqlite database at: {}", path.display()); - let db = crate::sqlite_adapter::rusqlite::Connection::open(&path)?; - db.pragma_update(None, "journal_mode", "WAL")?; - if opt.fsync { - db.pragma_update(None, "synchronous", "NORMAL")?; - } else { - db.pragma_update(None, "synchronous", "OFF")?; - } - Ok(crate::sqlite_adapter::SqliteDb::init(db)) + let manager = r2d2_sqlite::SqliteConnectionManager::file(path); + Ok(crate::sqlite_adapter::SqliteDb::new(manager, opt.fsync)?) } // ---- LMDB DB ---- |