mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
chore: mirror changes from BitBucket
This commit is contained in:
@ -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,)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user