db: Added Reverse lookup table (#147)

This commit is contained in:
Kartikeya Hegde
2022-12-19 18:50:05 +05:30
committed by GitHub
parent d6a3e508e2
commit 87fed68519
51 changed files with 937 additions and 201 deletions

View File

@ -25,7 +25,7 @@ async fn drainer_handler(
stream_index: u8,
max_read_count: u64,
) -> errors::DrainerResult<()> {
let stream_name = utils::get_drainer_stream(store.clone(), stream_index);
let stream_name = utils::get_drainer_stream_name(store.clone(), stream_index);
let drainer_result = drainer(store.clone(), max_read_count, stream_name.as_str()).await;
if let Err(_e) = drainer_result {
@ -70,6 +70,9 @@ async fn drainer(
kv::Insertable::PaymentAttempt(a) => {
macro_util::handle_resp!(a.insert(&conn).await, "ins", "pa")
}
kv::Insertable::Refund(a) => {
macro_util::handle_resp!(a.insert(&conn).await, "ins", "ref")
}
},
kv::DBOperation::Update { updatable } => match updatable {
kv::Updateable::PaymentIntentUpdate(a) => {
@ -78,6 +81,9 @@ async fn drainer(
kv::Updateable::PaymentAttemptUpdate(a) => {
macro_util::handle_resp!(a.orig.update(&conn, a.update_data).await, "up", "pa")
}
kv::Updateable::RefundUpdate(a) => {
macro_util::handle_resp!(a.orig.update(&conn, a.update_data).await, "up", "ref")
}
},
kv::DBOperation::Delete => todo!(),
};

View File

@ -113,9 +113,9 @@ pub fn increment_stream_index(index: u8, total_streams: u8) -> u8 {
}
pub(crate) fn get_stream_key_flag(store: Arc<router::services::Store>, stream_index: u8) -> String {
format!("{}_in_use", get_drainer_stream(store, stream_index))
format!("{}_in_use", get_drainer_stream_name(store, stream_index))
}
pub(crate) fn get_drainer_stream(store: Arc<Store>, stream_index: u8) -> String {
store.drainer_stream(format!("shard_{}", stream_index).as_str())
pub(crate) fn get_drainer_stream_name(store: Arc<Store>, stream_index: u8) -> String {
store.get_drainer_stream_name(format!("shard_{}", stream_index).as_str())
}