refactor: Return row id in IStore::retrieve_one

This is a prerequisite to synchronizing security ids stored via IDGenerator
(the "new" way to store ids, added when we implemented Deribit), and
SecurityDB (the original way from spark days). The problem was that these
2 implementations were using separate databases. We need to unify the
interfaces between these storage services to avoid breaking existing code.
This commit is contained in:
John Colvin committed 2024-11-20 22:17:08 +00:00
1 parent cb187e6997
commit bd8c97244a
28 files changed
+719 -566

No files matched your search

@@ -52,7 +52,7 @@ void add_or_update_to_table(
const std::string &ns,
const std::string &key,
const std::string &val) {
auto [exists, existing_val] = store->retrieve_one(ns, key);
auto [exists, rowid, existing_val] = store->retrieve_one(ns, key);
LOG(Gen, Info,
"add_or_update ns: {} key: {} val: {} exists: {} existing_val: {}", ns,
key, val, exists, existing_val);
@@ -386,7 +386,8 @@ void AnalyticsServiceServer::save_report(
const api::Response<::bts::api::ResultMessage> &resp) {
Report report = report_arg;
std::string key = std::to_string(report.id());
auto [present, val] = me->reports_store->retrieve_one(me->reports_ns, key);
auto [present, rowid, val] =
me->reports_store->retrieve_one(me->reports_ns, key);
if (!present) {
int new_id = get_max_id(me->reports_store.get(), me->reports_ns) + 1;
report.set_id(new_id);
@@ -408,7 +409,8 @@ void AnalyticsServiceServer::delete_report(
const bts::api::analytics::IntWrapper &id,
const api::Response<::bts::api::ResultMessage> &resp) {
std::string key = std::to_string(id.data());
auto [present, val] = me->reports_store->retrieve_one(me->reports_ns, key);
auto [present, rowid, val] =
me->reports_store->retrieve_one(me->reports_ns, key);
api::ResultMessage res;
res.set_success(false);
if (!present) {