diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-03 12:12:25 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-03 12:12:25 +0200 |
commit | bd9ff432d716020d7235ece76257b60dc3ead95a (patch) | |
tree | fe2819ccf30bea4d0190b6b7de2efc8a02da61d0 /src/garage/server.rs | |
parent | df0877bbba91d210fa8a91bd095ca13e0ea2176f (diff) | |
download | garage-bd9ff432d716020d7235ece76257b60dc3ead95a.tar.gz garage-bd9ff432d716020d7235ece76257b60dc3ead95a.zip |
Garage works on sqlite, but it's a hack
Diffstat (limited to 'src/garage/server.rs')
-rw-r--r-- | src/garage/server.rs | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/garage/server.rs b/src/garage/server.rs index b102067e..bd34456d 100644 --- a/src/garage/server.rs +++ b/src/garage/server.rs @@ -32,15 +32,32 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> { let config = read_config(config_file).expect("Unable to read config file"); info!("Opening database..."); - let mut db_path = config.metadata_dir.clone(); - db_path.push("db"); - let db = db::sled_adapter::sled::Config::default() - .path(&db_path) - .cache_capacity(config.sled_cache_capacity) - .flush_every_ms(Some(config.sled_flush_every_ms)) - .open() - .expect("Unable to open sled DB"); - let db = db::sled_adapter::SledDb::init(db); + let db = match config.db_engine.as_str() { + "sled" => { + let mut db_path = config.metadata_dir.clone(); + db_path.push("db"); + let db = db::sled_adapter::sled::Config::default() + .path(&db_path) + .cache_capacity(config.sled_cache_capacity) + .flush_every_ms(Some(config.sled_flush_every_ms)) + .open() + .expect("Unable to open sled DB"); + db::sled_adapter::SledDb::init(db) + } + "sqlite" => { + let mut db_path = config.metadata_dir.clone(); + db_path.push("db.sqlite"); + let db = db::sqlite_adapter::rusqlite::Connection::open(db_path) + .expect("Unable to open sqlite DB"); + db::sqlite_adapter::SqliteDb::init(db) + } + e => { + return Err(Error::Message(format!( + "Unsupported DB engine: {} (options: sled, sqlite)", + e + ))); + } + }; info!("Initializing background runner..."); let watch_cancel = netapp::util::watch_ctrl_c(); |