Changing archive_theos args in AnalyticsService
This commit is contained in:
1 parent
65bda258e1
commit
adb77dafac
3 files changed
+25
-11
No files matched your search
@@ -49,7 +49,7 @@ message ArchivedSecurityTheo {
|
||||
}
|
||||
|
||||
message ArchivedTheoList {
|
||||
uint64 save_time = 10;
|
||||
uint64 save_time = 10[ (bts.api.key) = true ];
|
||||
// these are sec_tups that are part of this save
|
||||
repeated bts.api.SecurityTuple sec_tups = 20;
|
||||
repeated ArchivedSecurityTheo sec_theo = 30;
|
||||
@@ -198,7 +198,7 @@ service AnalyticsService {
|
||||
rpc clean_and_archive_theos(ArchivedTheoList) returns (bts.api.ResultMessage);
|
||||
// finds the archived_theo closest to this point
|
||||
rpc get_archived_theos(ArchivedTheoRetrieval) returns (ArchivedTheoList);
|
||||
rpc archived_theos(bts.api.VoidMessage) returns (stream ArchivedSecurityTheo);
|
||||
rpc archived_theos(bts.api.VoidMessage) returns (stream ArchivedTheoList);
|
||||
|
||||
/// reports
|
||||
rpc get_new_report_id(bts.api.VoidMessage)
|
||||
|
||||
@@ -133,6 +133,13 @@ struct AnalyticsServiceServer::PImpl {
|
||||
archived_theos_publisher(archived_theos_publisher_) {}
|
||||
};
|
||||
|
||||
void AnalyticsServiceServer::_publish_archived_theos(
|
||||
const api::analytics::ArchivedTheoList &l) {
|
||||
// remove all rows
|
||||
me->archived_theos_publisher.add_or_update(l);
|
||||
me->archived_theos_publisher.flush();
|
||||
}
|
||||
|
||||
AnalyticsServiceServer::AnalyticsServiceServer(
|
||||
bts::api::ServiceContext &context)
|
||||
: AnalyticsServiceBase(context),
|
||||
@@ -215,23 +222,24 @@ AnalyticsServiceServer::AnalyticsServiceServer(
|
||||
// archived theos
|
||||
{
|
||||
size_t n = 0;
|
||||
// ns_table is ns vs {key, val}[]
|
||||
auto ns_table = me->theos_store->retrieve_all();
|
||||
LOG(OrderMan, Info,
|
||||
"AnalyticsServiceServer::cons loaded archived_theos n: {}",
|
||||
ns_table.size());
|
||||
bts_assert(ns_table.size() == 0 || ns_table.size() == 1);
|
||||
for (const auto &ns_vals : ns_table) {
|
||||
for (const auto &kvp : ns_vals.second) {
|
||||
ArchivedTheoList theo_list;
|
||||
utils::pb::from_string(kvp.second, &theo_list);
|
||||
for (const auto &t : theo_list.sec_theo()) {
|
||||
n++;
|
||||
me->archived_theos_publisher.add_or_update(t);
|
||||
}
|
||||
_publish_archived_theos(theo_list);
|
||||
n += theo_list.sec_theo().size();
|
||||
}
|
||||
}
|
||||
LOG(Gen, Info,
|
||||
"AnalyticsServiceServer::AnalyticsServiceServer publishing theos n: "
|
||||
"{}",
|
||||
n);
|
||||
me->archived_theos_publisher.flush();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,14 +500,15 @@ void AnalyticsServiceServer::clean_and_archive_theos(
|
||||
fire_cb(resp, false, &err_msg);
|
||||
return;
|
||||
}
|
||||
for (const auto &t : theo_list.sec_theo()) {
|
||||
me->archived_theos_publisher.add_or_update(t);
|
||||
}
|
||||
// for (const auto &t : theo_list.sec_theo()) {
|
||||
// me->archived_theos_publisher.add_or_update(t);
|
||||
// }
|
||||
me->theos_store->remove_all(me->archived_theos_ns);
|
||||
const std::string &ns = me->archived_theos_ns;
|
||||
const std::string key = std::to_string(theo_list.save_time());
|
||||
const std::string key = "dont care"; //std::to_string(theo_list.save_time());
|
||||
std::string value = utils::pb::to_string(theo_list);
|
||||
me->theos_store->insert(ns, key, value);
|
||||
_publish_archived_theos(theo_list);
|
||||
fire_cb(resp, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/api/services/AnalyticsService.pb.h"
|
||||
#include "lib/api/services/AnalyticsService.server.pb.h"
|
||||
|
||||
namespace bts {
|
||||
@@ -17,6 +18,10 @@ class AnalyticsServiceServer
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
|
||||
private:
|
||||
void _publish_archived_theos(
|
||||
const api::analytics::ArchivedTheoList &total_state);
|
||||
|
||||
public:
|
||||
AnalyticsServiceServer(bts::api::ServiceContext &context);
|
||||
|
||||
|
||||
Reference in new issue
Block a user