Import upstream v0.16.22, stripped
Upstream commit: 474dd0229cb20cf513036619781ed97bd8073c3f Enterprise-only files removed or emptied: 63 Enterprise-only snippets removed: 117 in 50 files Dangling module declarations removed: 5 Cargo edits turning enterprise off: 14 Verification: clean Enterprise feature gates left for rebuilt features: 19 in 18 files Produced by tools/fork/strip.py. The full report is in docs/fork/strip-reports/ on main.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use crate::{BlobStore, backend::fs::FsStore, registry::bootstrap::Bootstrap};
|
||||
use registry::schema::{prelude::ObjectType, structs};
|
||||
|
||||
#[allow(unreachable_patterns)]
|
||||
impl BlobStore {
|
||||
pub async fn build(bp: &mut Bootstrap) -> Option<Self> {
|
||||
let result = match bp.setting_infallible::<structs::BlobStore>().await {
|
||||
structs::BlobStore::Default => return Some(BlobStore::Store(bp.data_store.clone())),
|
||||
#[cfg(feature = "foundation")]
|
||||
structs::BlobStore::FoundationDb(foundation_db_store) => {
|
||||
crate::backend::foundationdb::FdbStore::open(foundation_db_store)
|
||||
.await
|
||||
.map(BlobStore::Store)
|
||||
}
|
||||
#[cfg(feature = "postgres")]
|
||||
structs::BlobStore::PostgreSql(postgre_sql_store) => {
|
||||
crate::backend::postgres::PostgresStore::open(postgre_sql_store)
|
||||
.await
|
||||
.map(BlobStore::Store)
|
||||
}
|
||||
#[cfg(feature = "mysql")]
|
||||
structs::BlobStore::MySql(my_sql_store) => {
|
||||
crate::backend::mysql::MysqlStore::open(my_sql_store)
|
||||
.await
|
||||
.map(BlobStore::Store)
|
||||
}
|
||||
#[cfg(feature = "s3")]
|
||||
structs::BlobStore::S3(s3_store) => crate::backend::s3::S3Store::open(s3_store).await,
|
||||
#[cfg(feature = "azure")]
|
||||
structs::BlobStore::Azure(azure_store) => {
|
||||
crate::backend::azure::AzureStore::open(azure_store).await
|
||||
}
|
||||
structs::BlobStore::FileSystem(file_system_store) => {
|
||||
FsStore::open(file_system_store).await
|
||||
}
|
||||
_ => Err("Binary was not compiled with the selected blob store backend".to_string()),
|
||||
};
|
||||
|
||||
match result {
|
||||
Ok(store) => Some(store),
|
||||
Err(err) => {
|
||||
bp.build_error(ObjectType::BlobStore.singleton(), err);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user