/* * SPDX-FileCopyrightText: 2020 Stalwart Labs LLC * * 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 { let result = match bp.setting_infallible::().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 } // inbuxa: ST-23 to ST-29 structs::InMemoryStore::Sharded(sharded) => { let mut warnings = Vec::new(); let result = crate::backend::scaleout::ShardedInMemoryStore::open( sharded, "", &bp.data_store, &mut warnings, ) .await; for warning in warnings { bp.build_warning(ObjectType::InMemoryStore.singleton(), warning); } result } _ => 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 } } } }