diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-03 16:40:38 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-03 16:40:38 +0200 |
commit | 2d5541b0e7ed0939e99710f40d3859c05bc31175 (patch) | |
tree | bed4653c7073f927275c8f6aa0f870ea9d227f54 /src/garage | |
parent | f7a1c70089bf453554f5ae787da4865caf0ee5c4 (diff) | |
download | garage-2d5541b0e7ed0939e99710f40d3859c05bc31175.tar.gz garage-2d5541b0e7ed0939e99710f40d3859c05bc31175.zip |
Integrate LMDB with rest
Diffstat (limited to 'src/garage')
-rw-r--r-- | src/garage/server.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/garage/server.rs b/src/garage/server.rs index a56f124a..9a1aa975 100644 --- a/src/garage/server.rs +++ b/src/garage/server.rs @@ -36,6 +36,7 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> { let db = match config.db_engine.as_str() { "sled" => { db_path.push("db"); + info!("Opening Sled database at: {}", db_path.display()); let db = db::sled_adapter::sled::Config::default() .path(&db_path) .cache_capacity(config.sled_cache_capacity) @@ -46,13 +47,32 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> { } "sqlite" | "sqlite3" | "rusqlite" => { db_path.push("db.sqlite"); + info!("Opening Sqlite database at: {}", db_path.display()); let db = db::sqlite_adapter::rusqlite::Connection::open(db_path) .expect("Unable to open sqlite DB"); db::sqlite_adapter::SqliteDb::init(db) } + "lmdb" | "heed" => { + db_path.push("db.lmdb"); + info!("Opening LMDB database at: {}", db_path.display()); + std::fs::create_dir_all(&db_path).expect("Unable to create LMDB data directory"); + let map_size = if u32::MAX as usize == usize::MAX { + warn!("LMDB is not recommended on 32-bit systems, database size will be limited"); + 1usize << 30 // 1GB for 32-bit systems + } else { + 1usize << 40 // 1TB for 64-bit systems + }; + + let db = db::lmdb_adapter::heed::EnvOpenOptions::new() + .max_dbs(100) + .map_size(map_size) + .open(&db_path) + .expect("Unable to open LMDB DB"); + db::lmdb_adapter::LmdbDb::init(db) + } e => { return Err(Error::Message(format!( - "Unsupported DB engine: {} (options: sled, sqlite)", + "Unsupported DB engine: {} (options: sled, sqlite, lmdb)", e ))); } |