my head hurts from the f#
This commit is contained in:
1 parent
fe8f217587
commit
81d67f640b
23 files changed
+316
-77
No files matched your search
@@ -17,6 +17,8 @@
|
||||
#include "lib/api/services/MarketDataRelay.server.pb.h"
|
||||
#include "lib/api/public/ServiceContext.h"
|
||||
#include "lib/api/services/AdminService.client.pb.h"
|
||||
#include "lib/api/service_helpers/AdminServiceUtils.h"
|
||||
#include "lib/config/protos/cme_reference_data.pb.h"
|
||||
#ifndef _WIN32
|
||||
#include "lib/metrics/metrics.h"
|
||||
#endif
|
||||
@@ -357,7 +359,7 @@ public:
|
||||
if (groupiter != _groups.end()) {
|
||||
auto& group = groupiter->second;
|
||||
bool is_entitled = bypass_entitlement ||
|
||||
ch.exchange() == api::VENUE_SIM ||
|
||||
/*ch.exchange() == api::VENUE_SIM || */
|
||||
ch.exchange() == api::VENUE_BTS ||
|
||||
(entitlements && entitlements->count(ch.symbol()));
|
||||
fill(ch, *group, reply->add_channels(), is_entitled);
|
||||
@@ -517,28 +519,39 @@ QueryServerPtr run_query_server(const bts::api::ServiceContext& ctx, std::shared
|
||||
db.check_heartbeats(threadpool);
|
||||
});
|
||||
container->health_timer->start();
|
||||
|
||||
|
||||
// Subscribe to entitlement data
|
||||
container->entitlement_sub =
|
||||
container->admin_client.subscribe_md_permissions_data().subscribe([=](const api::admin::Md_permissions_dataUpdate& update) {
|
||||
auto entitlements = std::make_shared<std::unordered_map<uint32_t, Entitlements>>();
|
||||
for (const auto& row : update.all()) {
|
||||
if (row && row->enabled()) {
|
||||
auto iter = entitlements->find(row->user_id());
|
||||
if (iter == entitlements->end()) {
|
||||
Entitlements ents;
|
||||
ents.insert(row->symbol());
|
||||
entitlements->insert(iter, std::make_pair(row->user_id(), std::move(ents)));
|
||||
}
|
||||
else {
|
||||
iter->second.insert(row->symbol());
|
||||
container->admin_client.subscribe_md_entitlement_data().subscribe([=](const api::admin::Md_entitlement_dataUpdate& update) {
|
||||
const auto& all_updates = update.all();
|
||||
utils::Dispatcher::background().post([all_updates, container]()
|
||||
{
|
||||
const auto& cme_symb_mics = config::get<config::CmeSymbolMics>().cme_mic();
|
||||
auto entitlements = std::make_shared<std::unordered_map<uint32_t, Entitlements>>();
|
||||
for (const auto& row : all_updates) {
|
||||
if (row && row->enabled()) {
|
||||
for(auto mic=cme_symb_mics.begin();mic!=cme_symb_mics.end();mic++){
|
||||
if(api::CMEMics_Name(mic->second) == row->mic()) {
|
||||
const auto& symbol = mic->first;
|
||||
auto iter = entitlements->find(row->user_id());
|
||||
if (iter == entitlements->end()) {
|
||||
Entitlements ents;
|
||||
ents.insert(symbol);
|
||||
ents.insert("SIM:" + symbol);
|
||||
entitlements->insert(iter, std::make_pair(row->user_id(), std::move(ents)));
|
||||
}
|
||||
else {
|
||||
iter->second.insert(symbol);
|
||||
iter->second.insert("SIM:" + symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
container->relay.update_entitlements(entitlements);
|
||||
container->relay.update_entitlements(entitlements);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Add a few threads to keep md latency low
|
||||
for (int x = 1; x < std::min(4, os::num_cores()); ++x) {
|
||||
threadpool.add_thread();
|
||||
|
||||
Reference in new issue
Block a user