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.
57 lines
2.1 KiB
Rust
57 lines
2.1 KiB
Rust
/*
|
|
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
|
*/
|
|
|
|
use crate::{
|
|
SearchStore,
|
|
backend::{elastic::ElasticSearchStore, meili::MeiliSearchStore},
|
|
registry::bootstrap::Bootstrap,
|
|
};
|
|
use registry::schema::{prelude::ObjectType, structs};
|
|
|
|
#[allow(unreachable_patterns)]
|
|
impl SearchStore {
|
|
pub async fn build(bp: &mut Bootstrap) -> Option<Self> {
|
|
let result = match bp.setting_infallible::<structs::SearchStore>().await {
|
|
structs::SearchStore::Default => {
|
|
return Some(SearchStore::Store(bp.data_store.clone()));
|
|
}
|
|
structs::SearchStore::ElasticSearch(elastic_search_store) => {
|
|
ElasticSearchStore::open(elastic_search_store).await
|
|
}
|
|
structs::SearchStore::Meilisearch(meilisearch_store) => {
|
|
MeiliSearchStore::open(meilisearch_store).await
|
|
}
|
|
#[cfg(feature = "foundation")]
|
|
structs::SearchStore::FoundationDb(foundation_db_store) => {
|
|
crate::backend::foundationdb::FdbStore::open(foundation_db_store)
|
|
.await
|
|
.map(SearchStore::Store)
|
|
}
|
|
#[cfg(feature = "postgres")]
|
|
structs::SearchStore::PostgreSql(postgre_sql_store) => {
|
|
crate::backend::postgres::PostgresStore::open(postgre_sql_store)
|
|
.await
|
|
.map(SearchStore::Store)
|
|
}
|
|
#[cfg(feature = "mysql")]
|
|
structs::SearchStore::MySql(my_sql_store) => {
|
|
crate::backend::mysql::MysqlStore::open(my_sql_store)
|
|
.await
|
|
.map(SearchStore::Store)
|
|
}
|
|
_ => Err("Binary was not compiled with the selected search store backend".to_string()),
|
|
};
|
|
|
|
match result {
|
|
Ok(store) => Some(store),
|
|
Err(err) => {
|
|
bp.build_error(ObjectType::SearchStore.singleton(), err);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|