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,41 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use crate::{InMemoryStore, registry::bootstrap::Bootstrap};
|
||||
use registry::schema::{prelude::ObjectType, structs};
|
||||
|
||||
#[allow(unreachable_patterns)]
|
||||
impl InMemoryStore {
|
||||
pub async fn build(bp: &mut Bootstrap) -> Option<Self> {
|
||||
let result = match bp.setting_infallible::<structs::InMemoryStore>().await {
|
||||
structs::InMemoryStore::Default => {
|
||||
return Some(InMemoryStore::Store(bp.data_store.clone()));
|
||||
}
|
||||
#[cfg(feature = "redis")]
|
||||
structs::InMemoryStore::Redis(redis_store) => {
|
||||
crate::backend::redis::RedisStore::open_single(redis_store).await
|
||||
}
|
||||
#[cfg(feature = "redis")]
|
||||
structs::InMemoryStore::RedisCluster(redis_cluster_store) => {
|
||||
crate::backend::redis::RedisStore::open_cluster(redis_cluster_store).await
|
||||
}
|
||||
#[cfg(feature = "redis")]
|
||||
structs::InMemoryStore::RedisSentinel(redis_sentinel_store) => {
|
||||
crate::backend::redis::RedisStore::open_sentinel(redis_sentinel_store).await
|
||||
}
|
||||
_ => Err("Binary was not compiled with the selected in-memory backend".to_string()),
|
||||
};
|
||||
|
||||
match result {
|
||||
Ok(store) => Some(store),
|
||||
Err(err) => {
|
||||
bp.build_error(ObjectType::InMemoryStore.singleton(), err);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user