Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(payments): add api locking for payments core #1898

Merged
merged 26 commits into from
Sep 25, 2023
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
18d824c
feat(core): add api locking interface
Abhicodes-crypto Feb 23, 2023
dff1051
feat(payments): add api-locking for payments core
Abhicodes-crypto Aug 8, 2023
d2480b3
refactor: clean up
Abhicodes-crypto Aug 8, 2023
797234c
fix: cargo hack
Abhicodes-crypto Aug 10, 2023
9a1faf2
reafactor: remove code comments
Abhicodes-crypto Aug 10, 2023
9fadcb9
refactor: resolve comments
Abhicodes-crypto Aug 23, 2023
ec4d52c
refactor: rename feature to api_locking
Abhicodes-crypto Aug 23, 2023
2ebc891
temp
Abhicodes-crypto Aug 23, 2023
0ae0995
refactor: Merge commit a58cccc from main
Abhicodes-crypto Sep 12, 2023
4249620
refactor(api-locking): reduce the functions in locking and add consta…
Abhicodes-crypto Sep 13, 2023
8be8ad3
refactor: use lock function in server_wrap
Abhicodes-crypto Sep 13, 2023
6ba6caf
refactor: add locking action paramter in server_wrap
Abhicodes-crypto Sep 14, 2023
a49912e
refactor: add locking_action in server_Wrap and call lock functions i…
Abhicodes-crypto Sep 14, 2023
9b873ae
feat: add lock in payments webhooks flow
Abhicodes-crypto Sep 15, 2023
2819271
refactor: move api locking consts into settings
Abhicodes-crypto Sep 15, 2023
bbd6218
refactor: del unnecessary file
Abhicodes-crypto Sep 15, 2023
8136e31
fix: stack overflow error in update config
Abhicodes-crypto Sep 15, 2023
a8660ee
refactor: put lock env in settings
Abhicodes-crypto Sep 20, 2023
2eb2460
feat(locking): validate request_id before releasing lock
Abhicodes-crypto Sep 20, 2023
e455d69
Merge main to api-locking
Abhicodes-crypto Sep 21, 2023
e0faae9
feat(locking): add lock settings in developement.toml and add validat…
Abhicodes-crypto Sep 21, 2023
d5db2ff
feat(locking): address comments
Abhicodes-crypto Sep 22, 2023
1c3c1e2
Merge main to api-locking
Abhicodes-crypto Sep 22, 2023
25e573f
Merge main to api-locking
Abhicodes-crypto Sep 22, 2023
442dee8
refactor: update open api spec
Abhicodes-crypto Sep 22, 2023
14c7bb4
fix: capture request skip deserialize payment_id
Abhicodes-crypto Sep 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge main to api-locking
  • Loading branch information
Abhicodes-crypto committed Sep 22, 2023
commit 25e573f09acdf2753d3cea376b2ec426b04080c5
41 changes: 1 addition & 40 deletions crates/router/src/db/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl ConfigInterface for Store {
.map_err(Into::into)
.into_report()
}

//check in cache, then redis then finally DB, and on the way back populate redis and cache
async fn find_config_by_key(
&self,
Expand Down Expand Up @@ -154,45 +154,6 @@ impl ConfigInterface for Store {
cache::get_or_populate_in_memory(self, key, find_else_unwrap_or, &CONFIG_CACHE).await
}

async fn find_config_by_key_unwrap_or(
&self,
key: &str,
// If the config is not found it will be created with the default value.
default_config: Option<String>,
) -> CustomResult<storage::Config, errors::StorageError> {
let find_else_unwrap_or = || async {
let conn = connection::pg_connection_write(self).await?;
match storage::Config::find_by_key(&conn, key)
.await
.map_err(Into::<errors::StorageError>::into)
.into_report()
{
Ok(a) => Ok(a),
Err(err) => {
if err.current_context().is_db_not_found() {
default_config
.ok_or(err)
.async_and_then(|c| async {
storage::ConfigNew {
key: key.to_string(),
config: c,
}
.insert(&conn)
.await
.map_err(Into::into)
.into_report()
})
.await
} else {
Err(err)
}
}
}
};

cache::get_or_populate_in_memory(self, key, find_else_unwrap_or, &CONFIG_CACHE).await
}

async fn delete_config_by_key(&self, key: &str) -> CustomResult<bool, errors::StorageError> {
let conn = connection::pg_connection_write(self).await?;
let deleted = storage::Config::delete_by_key(&conn, key)
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.