chore: mirror changes from BitBucket

This commit is contained in:
Sanchith Hegde
2022-11-21 18:47:04 +05:30
parent df5e4defd3
commit 2a2febb0f8
76 changed files with 2219 additions and 744 deletions

View File

@ -11,4 +11,33 @@ pub use self::{api::*, encryption::*};
pub struct Store {
pub pg_pool: crate::db::SqlDb,
pub redis_conn: Arc<crate::services::redis::RedisConnectionPool>,
#[cfg(feature = "kv_store")]
pub(crate) config: StoreConfig,
}
#[cfg(feature = "kv_store")]
#[derive(Clone)]
pub(crate) struct StoreConfig {
pub(crate) drainer_stream_name: String,
pub(crate) drainer_num_partitions: u8,
}
impl Store {
pub async fn new(config: &crate::configs::settings::Settings) -> Self {
Self {
pg_pool: crate::db::SqlDb::new(&config.database).await,
redis_conn: Arc::new(crate::connection::redis_connection(config).await),
#[cfg(feature = "kv_store")]
config: StoreConfig {
drainer_stream_name: config.drainer.stream_name.clone(),
drainer_num_partitions: config.drainer.num_partitions,
},
}
}
#[cfg(feature = "kv_store")]
pub fn drainer_stream(&self, shard_key: &str) -> String {
// "{shard_key}_stream_name"
format!("{{{}}}_{}", shard_key, self.config.drainer_stream_name,)
}
}