mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
config: convert database backend to enum
This reports a nice error when the config is loaded, rather than later when the database is initialized.
This commit is contained in:
parent
d26b87a2f2
commit
8a30817930
3 changed files with 40 additions and 11 deletions
|
|
@ -153,9 +153,29 @@ impl Default for TurnConfig {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub(crate) enum DatabaseBackend {
|
||||
#[cfg(feature = "rocksdb")]
|
||||
Rocksdb,
|
||||
#[cfg(feature = "sqlite")]
|
||||
Sqlite,
|
||||
}
|
||||
|
||||
impl Display for DatabaseBackend {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
#[cfg(feature = "rocksdb")]
|
||||
DatabaseBackend::Rocksdb => write!(f, "RocksDB"),
|
||||
#[cfg(feature = "sqlite")]
|
||||
DatabaseBackend::Sqlite => write!(f, "SQLite"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub(crate) struct DatabaseConfig {
|
||||
pub(crate) backend: String,
|
||||
pub(crate) backend: DatabaseBackend,
|
||||
pub(crate) path: String,
|
||||
#[serde(default = "default_db_cache_capacity_mb")]
|
||||
pub(crate) cache_capacity_mb: f64,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue