Merge
This commit is contained in:
commit
a400750a86
15 files changed
+243
-68
No files matched your search
@@ -0,0 +1,134 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.10
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_api", "src\client\spark_api\spark_api.csproj", "{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spark_lib", "build\src\lib\spark_lib.vcxproj", "{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spark", "src\client\spark\Spark.csproj", "{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sparkcmd", "src\client\sparkcmd\sparkcmd.csproj", "{387566C6-C6F6-412C-A30C-9855BBCB4816}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_core", "src\client\spark_core\spark_core.csproj", "{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
MinSizeRel|Any CPU = MinSizeRel|Any CPU
|
||||
MinSizeRel|x64 = MinSizeRel|x64
|
||||
MinSizeRel|x86 = MinSizeRel|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
RelWithDebInfo|Any CPU = RelWithDebInfo|Any CPU
|
||||
RelWithDebInfo|x64 = RelWithDebInfo|x64
|
||||
RelWithDebInfo|x86 = RelWithDebInfo|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|x64.Build.0 = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x86.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Debug|x64.Build.0 = Debug|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.MinSizeRel|Any CPU.ActiveCfg = MinSizeRel|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Release|x64.ActiveCfg = Release|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Release|x64.Build.0 = Release|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.Release|x86.ActiveCfg = Release|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{9186D3A8-1C5C-372A-A4EE-E1045BCCB0C7}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x64.Build.0 = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|x64.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|x64.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Release|x86.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x64.Build.0 = Debug|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x64.ActiveCfg = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x64.Build.0 = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.Release|x86.ActiveCfg = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{387566C6-C6F6-412C-A30C-9855BBCB4816}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|x64.Build.0 = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|Any CPU.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x86.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x86.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|x86.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x86.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x86.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {422D1620-0166-4C26-9A81-CA8A2EB1AB58}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -21,6 +21,7 @@
|
||||
<Proto3 Include="**/*.proto" />
|
||||
<Proto3 Include="../../lib/api/*.proto" />
|
||||
<Proto3 Include="../../lib/api/services/*.proto" />
|
||||
<Proto3 Remove="../../lib/api/services/MarketDataRelay.proto" />
|
||||
<Proto2 Include="../../lib/config/protos/*.proto" />
|
||||
<Proto2 Include="../../lib/security_model/Security.proto" />
|
||||
<Proto3 Update="../../lib/api/services/OutOfProcessURLListener.proto">
|
||||
|
||||
@@ -36,6 +36,7 @@ set (Service_Protos
|
||||
api/services/MarketDataService.proto
|
||||
api/services/PersistenceService.proto
|
||||
api/services/UserService.proto
|
||||
api/services/MarketDataRelay.proto
|
||||
)
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/tools/Protobuf.cmake)
|
||||
|
||||
@@ -44,15 +44,15 @@ using namespace rxcpp::operators;
|
||||
|
||||
{{else}}
|
||||
|
||||
void {{../name}}::{{name}}(const {{input_type}}& input, std::function<void(Result<{{output_type}}>)> callback, uint32_t timeout_ms) {
|
||||
void {{../name}}::{{name}}(const {{input_type}}& input, std::function<void(bts::api::Result<{{output_type}}>)> callback, uint32_t timeout_ms) {
|
||||
_pchannel->send({{@index}}, input, callback);
|
||||
}
|
||||
|
||||
Result<{{output_type}}> {{../name}}::{{name}}(const {{input_type}}& input, uint32_t timeout_ms) {
|
||||
bts::api::Result<{{output_type}}> {{../name}}::{{name}}(const {{input_type}}& input, uint32_t timeout_ms) {
|
||||
if (_pchannel->is_sync_call_ok()) {
|
||||
std::promise<Result<{{output_type}}>> p;
|
||||
std::promise<bts::api::Result<{{output_type}}>> p;
|
||||
auto future = p.get_future();
|
||||
{{name}}(input, [&](Result<{{output_type}}> res) {
|
||||
{{name}}(input, [&](bts::api::Result<{{output_type}}> res) {
|
||||
p.set_value(res);
|
||||
}, timeout_ms);
|
||||
future.wait();
|
||||
|
||||
@@ -47,7 +47,7 @@ void {{name}}Base::dispatch(const bts::api::RequestHeader& header, google::proto
|
||||
default: {
|
||||
bts::api::ResponseHeader response;
|
||||
response.set_request_id(header.request_id());
|
||||
response.set_code(ApiError::MISSING_METHOD);
|
||||
response.set_code(bts::api::ApiError::MISSING_METHOD);
|
||||
uint8_t buffer[64];
|
||||
int header_size = response.ByteSize() + 1;
|
||||
serialize(header_size, response, buffer);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
syntax="proto3";
|
||||
package bts.co2;
|
||||
import "lib/api/apioptions.proto";
|
||||
import "lib/md/protos/co2.proto";
|
||||
|
||||
service MarketDataRelay {
|
||||
option (bts.api.service_description)="Poll the market data service for updates";
|
||||
rpc requestmd(bts.co2.MDRequest) returns (bts.co2.MDReply);
|
||||
}
|
||||
@@ -104,4 +104,4 @@ message SecurityRequest { }
|
||||
|
||||
service MarketDataService {
|
||||
rpc securities(SecurityRequest) returns (stream Security);
|
||||
}
|
||||
}
|
||||
@@ -162,11 +162,11 @@ CAPI void add_relay_symbol(md::RelayControl* prelay, BlitUserSymbol& symbol, uin
|
||||
get_system_md_symbols(channel.exchange(), channel.type(), system_symbols);
|
||||
for (const auto& sym : system_symbols) {
|
||||
channel.set_symbol(sym.symbol());
|
||||
md::add_relay_symbol(prelay, channel);
|
||||
//md::add_relay_symbol(prelay, channel);
|
||||
}
|
||||
}
|
||||
else {
|
||||
md::add_relay_symbol(prelay, channel);
|
||||
//md::add_relay_symbol(prelay, channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,11 @@
|
||||
|
||||
#include "lib/config/protos/system.pb.h"
|
||||
#include "lib/md/protos/co2.pb.h"
|
||||
#include "lib/api/services/MarketDataRelay.server.pb.h"
|
||||
#include "lib/api/public/ServiceContext.h"
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <google/protobuf/arena.h>
|
||||
@@ -172,8 +175,8 @@ void copy_misc(MiscData misc, co2::MiscMessage* pmisc) {
|
||||
}
|
||||
|
||||
// Handles market data queries and responds
|
||||
struct QueryServer : public IQueryServer {
|
||||
QueryServer(const std::set<UserSymbol>& symbols) :
|
||||
struct QueryServerImpl : public IQueryServer {
|
||||
QueryServerImpl(const std::set<UserSymbol>& symbols) :
|
||||
groups(form_groups(symbols))
|
||||
{ }
|
||||
|
||||
@@ -322,61 +325,75 @@ private:
|
||||
Map groups;
|
||||
};
|
||||
|
||||
/// In the future this might be replaced by a Service
|
||||
// struct PubSubRpcServer : public pubsub::RPCHandler<MDRequest, MDReply>
|
||||
// {
|
||||
// const QueryServer& _db;
|
||||
// utils::Dispatcher& _threadpool;
|
||||
// PubSubRpcServer(const QueryServer& db, pubsub::PubsubHub& hub, utils::Dispatcher& threadpool) :
|
||||
// pubsub::RPCHandler<MDRequest, MDReply>(hub, "/md/rpc"),
|
||||
// _db(db),
|
||||
// _threadpool(threadpool)
|
||||
// { }
|
||||
//
|
||||
// // Inherited via RPCHandler
|
||||
// virtual void handle(pubsub::msgs::Request const & request_id, MDRequest const & request) override {
|
||||
// _threadpool.post([=]() {
|
||||
// google::protobuf::Arena arena;
|
||||
// MDReply* preply = google::protobuf::Arena::CreateMessage<MDReply>(&arena);
|
||||
// TimeStamp start = TimeStamp::now();
|
||||
// _db.query(request, preply);
|
||||
// auto elapsed = (TimeStamp::now() - start);
|
||||
// LOG(Diag, MarketData) << "Request for: " << request.host() << " took " << (elapsed.microseconds()) << "us and returned " << preply->ByteSize() << " bytes before compression";
|
||||
// reply(request_id, *preply);
|
||||
// });
|
||||
// }
|
||||
// };
|
||||
struct MDRelayServer : bts::co2::MarketDataRelayBase {
|
||||
const QueryServerImpl& _db;
|
||||
utils::Dispatcher& _threadpool;
|
||||
MDRelayServer(const QueryServerImpl& db, utils::Dispatcher& threadpool, bts::api::ServiceContext ctx) :
|
||||
bts::co2::MarketDataRelayBase(ctx),
|
||||
_db(db), _threadpool(threadpool)
|
||||
{ }
|
||||
|
||||
virtual void requestmd(const MDRequest & request, std::function<void(const MDReply&)> reply) override {
|
||||
_threadpool.post([=]() {
|
||||
google::protobuf::Arena arena;
|
||||
MDReply* preply = google::protobuf::Arena::CreateMessage<MDReply>(&arena);
|
||||
TimeStamp start = TimeStamp::now();
|
||||
_db.query(request, preply);
|
||||
auto elapsed = (TimeStamp::now() - start);
|
||||
LOG(MarketData, Diag,
|
||||
"Request for: {} took {}us and returned {} bytes before compression",
|
||||
request.host(),
|
||||
elapsed.microseconds(),
|
||||
preply->ByteSize());
|
||||
reply(*preply);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
struct QueryServer {
|
||||
QueryServer(std::set<UserSymbol> symbols, utils::Dispatcher& threadpool, const bts::api::ServiceContext& ctx):
|
||||
db(symbols),
|
||||
relay(db, threadpool, ctx),
|
||||
security_timer(),
|
||||
health_timer()
|
||||
{ }
|
||||
QueryServerImpl db;
|
||||
MDRelayServer relay;
|
||||
std::unique_ptr<utils::DispatcherTimer> security_timer;
|
||||
std::unique_ptr<utils::DispatcherTimer> health_timer;
|
||||
};
|
||||
|
||||
// void run_query_server() {
|
||||
// pubsub::PubsubHub hub(
|
||||
// config::get<config::PubsubHost>().host(),
|
||||
// config::get<config::Ports>().edge_md_pubsub_port());
|
||||
// std::set<UserSymbol> all_symbols;
|
||||
// get_system_md_symbols(config::get<PlatformConfig>().exchange(), config::get<PlatformConfig>().type(), all_symbols);
|
||||
// QueryServer db(all_symbols);
|
||||
// utils::Dispatcher& dispatcher = utils::Dispatcher::current();
|
||||
// PubSubRpcServer server(db, hub, dispatcher);
|
||||
// server.start();
|
||||
//
|
||||
// // Scan for new securities every half second
|
||||
// utils::DispatcherTimer security_timer(dispatcher, config::get<RelayOptions>().security_scan_interval(), [&db]() {
|
||||
// db.scan_securities();
|
||||
// });
|
||||
// security_timer.start();
|
||||
//
|
||||
// // Scan for dead producers every 30 seconds
|
||||
// utils::DispatcherTimer health_timer(dispatcher, config::get<RelayOptions>().recovery_interval(), [&db]() {
|
||||
// db.check_heartbeats(utils::Dispatcher::current());
|
||||
// });
|
||||
// health_timer.start();
|
||||
//
|
||||
// utils::Dispatcher::current().run(std::min(4,os::num_cores()));
|
||||
// }
|
||||
QueryServerPtr run_query_server(const bts::api::ServiceContext& ctx) {
|
||||
auto& threadpool = utils::Dispatcher::get_named("MDQuery");
|
||||
|
||||
std::set<UserSymbol> all_symbols;
|
||||
get_system_md_symbols(config::get<PlatformConfig>().exchange(), config::get<PlatformConfig>().type(), all_symbols);
|
||||
QueryServerPtr container = std::make_shared<QueryServer>(all_symbols, threadpool, ctx);
|
||||
auto& db = container->db;
|
||||
|
||||
// std::unique_ptr<IQueryServer> create_query_server(const std::set<md2::UserSymbol>& symbols) {
|
||||
// return utils::make_unique<QueryServer>(symbols);
|
||||
// }
|
||||
// Scan for new securities every half second
|
||||
container->security_timer = std::make_unique<utils::DispatcherTimer>(threadpool, config::get<RelayOptions>().security_scan_interval(), [&db]() {
|
||||
db.scan_securities();
|
||||
});
|
||||
container->security_timer->start();
|
||||
|
||||
// Scan for dead producers every 30 seconds
|
||||
container->health_timer = std::make_unique<utils::DispatcherTimer>(threadpool, config::get<RelayOptions>().recovery_interval(), [&db, &threadpool]() {
|
||||
db.check_heartbeats(threadpool);
|
||||
});
|
||||
container->health_timer->start();
|
||||
|
||||
// Add a few threads to keep md latency low
|
||||
for (int x = 1; x < std::min(4, os::num_cores()); ++x) {
|
||||
threadpool.add_thread();
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
std::unique_ptr<IQueryServer> create_query_server(const std::set<md2::UserSymbol>& symbols) {
|
||||
return std::make_unique<QueryServerImpl>(symbols);
|
||||
}
|
||||
|
||||
}}//namespace
|
||||
#endif
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "lib/md/protos/co2.pb.h"
|
||||
|
||||
namespace bts {
|
||||
namespace api { class ServiceContext; }
|
||||
namespace md {
|
||||
|
||||
struct IQueryServer {
|
||||
@@ -18,7 +19,9 @@ struct IQueryServer {
|
||||
};
|
||||
std::unique_ptr<IQueryServer> create_query_server(const std::set<md2::UserSymbol>& symbols);
|
||||
|
||||
BTS_EXPORT void run_query_server();
|
||||
struct QueryServer;
|
||||
typedef std::shared_ptr<QueryServer> QueryServerPtr;
|
||||
BTS_EXPORT QueryServerPtr run_query_server(const bts::api::ServiceContext&);
|
||||
|
||||
}}//namespace
|
||||
|
||||
@@ -262,6 +262,9 @@ DispatcherTimer::DispatcherTimer(Dispatcher& dispatcher, int64_t time_ms, Action
|
||||
{
|
||||
}
|
||||
|
||||
DispatcherTimer::DispatcherTimer(DispatcherTimer&& other) : _me(std::move(other._me)) {}
|
||||
|
||||
|
||||
DispatcherTimer::~DispatcherTimer() { }
|
||||
|
||||
void DispatcherTimer::start()
|
||||
|
||||
@@ -97,6 +97,7 @@ class BTS_EXPORT DispatcherTimer
|
||||
{
|
||||
public:
|
||||
DispatcherTimer(Dispatcher& dispatcher, int64_t time_ms, Action cb);
|
||||
DispatcherTimer(DispatcherTimer&& other);
|
||||
~DispatcherTimer();
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "server/sparkd/persistence/PersistenceServiceServer.h"
|
||||
#include "server/sparkd/user/UserServiceServer.h"
|
||||
#include "lib/md/relay/QueryServer.h"
|
||||
|
||||
namespace bts {
|
||||
namespace setup {
|
||||
@@ -25,14 +26,17 @@ struct ServiceHostActor::PImpl
|
||||
PImpl() : quickbus(make_cfg(),qbus::Quickbus::ThreadOptions::outside_thread),
|
||||
service_context(&quickbus),
|
||||
settings_saver(service_context,"settings"),
|
||||
login_server(service_context)
|
||||
{}
|
||||
login_server(service_context),
|
||||
md_query_server(md::run_query_server(service_context))
|
||||
{
|
||||
}
|
||||
qbus::Quickbus quickbus;
|
||||
api::ServiceContext service_context;
|
||||
|
||||
// hosted services
|
||||
persistence::PersistenceServiceServer settings_saver;
|
||||
user::UserServiceServer login_server;
|
||||
md::QueryServerPtr md_query_server;
|
||||
};
|
||||
|
||||
ServiceHostActor::ServiceHostActor () : me (new PImpl()) {}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G "Visual Studio 15 2017 Win64" ..
|
||||
@setlocal
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G "Visual Studio 15 2017 Win64" ..
|
||||
@@ -1,5 +1,6 @@
|
||||
#/bin/bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
mkdir -p $DIR/../build/
|
||||
cd $DIR/../build/
|
||||
|
||||
rm -rf gcc_debug
|
||||
|
||||
Reference in new issue
Block a user