This new structure provides several benefits:
* Allows us to install multiple CMake projects in the same destination
dir (without include path conflicts).
- This makes shipping the trading algo sdk a trivial excercise. Simply
copy the lib and include dirs from the install dest. That's it!
* Puts us in a position to break up the monolithic libspark into smaller
modules, which are easier to manage.
74 lines
2.3 KiB
C++
74 lines
2.3 KiB
C++
#include "Web.h"
|
|
#include "spark/api/public/ServiceContext.h"
|
|
#include "spark/api/services/MarketDataService.pb.h"
|
|
#include "spark/api/services/SyntheticSecurityService.pb.h"
|
|
#include "spark/config/config.h"
|
|
#include "spark/config/protos/market_data.pb.h"
|
|
#include "spark/config/protos/ports.pb.h"
|
|
#include "spark/config/protos/quickbus_cfg.pb.h"
|
|
#include "spark/md/MBOProcessor.h"
|
|
#include "spark/md/MDClient.h"
|
|
#include "spark/md/SyntheticSecurityService.h"
|
|
#include "spark/md/relay/QueryServer.h"
|
|
#include "spark/metrics/metrics.h"
|
|
#include "spark/metrics/system_metrics.h"
|
|
#include "spark/quickbus/quickbus.h"
|
|
#include "spark/tracing/PerfLog.h"
|
|
#include "spark/utils/Dispatcher.h"
|
|
#include "spark/utils/thread_manager.h"
|
|
#include "md/cmds/Cleanup.h"
|
|
#include "md/cmds/Run.h"
|
|
#include "sparkd/exchange_sim/ExchangeSim.h"
|
|
#include "sparkd/http/WebServer.h"
|
|
#include "sparkd/user/AdminServiceServer.h"
|
|
#include "sparkd/user/AuthServiceServer.h"
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace bts::cmds {
|
|
|
|
struct Web::Args {
|
|
bool md;
|
|
};
|
|
|
|
Web::Web()
|
|
: CLI::App(
|
|
"Run only the services required for the web admin. This cannot be "
|
|
"run concurrently with 'sparkd run.'",
|
|
"web"),
|
|
_args(new Web::Args()) {
|
|
add_flag("--md", _args->md, "Start market data");
|
|
callback([&] {
|
|
auto qb_cfg = config::get<config::QuickbusCfg>().node();
|
|
auto &ports = config::get<config::Ports>();
|
|
qb_cfg.set_my_port(ports.qbus_port());
|
|
qbus::Quickbus quickbus(qb_cfg);
|
|
bts::api::ServiceContext sc(&quickbus);
|
|
|
|
bts::metrics::MetricsContainer stats;
|
|
metrics::publish_system_metrics(stats);
|
|
trace::PerfLog perf_log;
|
|
http::SparkWebServer webserver(sc, stats, perf_log, ports.config_port());
|
|
|
|
user::AuthServiceServer login_server(sc);
|
|
if (_args->md) {
|
|
md::cmds::Run::run();
|
|
}
|
|
|
|
bts::api::synthetic::SyntheticSecurityService synthetic_service(sc);
|
|
bts::admin::AdminServiceServer admin_service(sc);
|
|
bts::md::MDClient mdclient(
|
|
&bts::utils::Dispatcher::current(), &synthetic_service);
|
|
|
|
bts::md::QueryServerPtr md_query_server(
|
|
bts::md::run_query_server(sc, mdclient, stats));
|
|
|
|
bts::utils::Dispatcher::current().run();
|
|
});
|
|
}
|
|
|
|
Web::~Web() {}
|
|
|
|
} // namespace bts::cmds
|