123 lines
4.3 KiB
C++
123 lines
4.3 KiB
C++
// #include "lib/orderman_v2/OrderManEngine.h"
|
|
// #include "lib/config/protos/orderman_cfg.pb.h"
|
|
// #include "lib/md/MDConsumer.h"
|
|
// #include "lib/orderman_v2/Thread.h"
|
|
// #include "lib/orderman_v2/components.h"
|
|
// #include <fmt/format.h>
|
|
|
|
// namespace bts {
|
|
// namespace orderman_v2 {
|
|
|
|
// struct ThreadRec {
|
|
// ThreadRec(config::OrderManThreadingCfg::Thread const &t_cfg)
|
|
// : thread(t_cfg.name(), t_cfg.poll()), cfg(t_cfg) {}
|
|
|
|
// Thread thread;
|
|
// config::OrderManThreadingCfg::Thread cfg;
|
|
// };
|
|
|
|
// struct MDSourceOM {
|
|
// MDSourceOM(md::MDConsumer &md) : md_source(md), manager() {}
|
|
// MDSource md_source;
|
|
// OrderManager manager;
|
|
// };
|
|
|
|
|
|
// struct OrderManEngine::PImpl {
|
|
// PImpl(md::MDConsumer &md) : md_consumer(md) {}
|
|
|
|
// std::map<std::string, std::unique_ptr<ThreadRec>> threads;
|
|
|
|
// Component<ServiceBridge> service_bridge;
|
|
// Component<Storage> storage;
|
|
// std::vector<Component<MDSourceOM>> order_managers;
|
|
// std::vector<Component<Gateway>> gateways;
|
|
|
|
// md::MDConsumer &md_consumer;
|
|
// };
|
|
|
|
// OrderManEngine::OrderManEngine(md::MDConsumer &md,
|
|
// config::OrderManThreadingCfg const &cfg)
|
|
// : me(new PImpl(md)) {
|
|
// init_threads(cfg);
|
|
// init_components();
|
|
// }
|
|
|
|
// void OrderManEngine::init_threads(config::OrderManThreadingCfg const &cfg) {
|
|
// for (auto const &t_cfg : cfg.thread()) {
|
|
// auto &thread_ptr = me->threads[t_cfg.name()];
|
|
// bts_assert_msg(
|
|
// !thread_ptr,
|
|
// fmt::format("Duplicate thread name {} in OrderManThreading "
|
|
// "configuration key",
|
|
// t_cfg.name()));
|
|
// thread_ptr = std::make_unique<ThreadRec>(t_cfg);
|
|
// }
|
|
// bts_assert("No threads in OrderManThreading configuration key");
|
|
// }
|
|
|
|
// void OrderManEngine::init_components() {
|
|
// for (auto const &p : me->threads) {
|
|
// auto const &tr = p.second;
|
|
|
|
// for (auto const &c : tr->cfg.component()) {
|
|
|
|
// if (c.name() == "service_bridge") {
|
|
// bts_assert_msg(!me->service_bridge.component,
|
|
// "Duplicate service_bridge component found in "
|
|
// "OrderManThreading configuration key");
|
|
|
|
// me->service_bridge.thread = &tr->thread;
|
|
// me->service_bridge.component = std::make_unique<ServiceBridge>();
|
|
// continue;
|
|
// }
|
|
|
|
// if (c.name() == "storage") {
|
|
// bts_assert_msg(!me->storage.component,
|
|
// "Duplicate storage component found in "
|
|
// "OrderManThreading configuration key");
|
|
|
|
// me->storage.thread = &tr->thread;
|
|
// me->storage.component = std::make_unique<Storage>();
|
|
// continue;
|
|
// }
|
|
|
|
// if (c.name() == "order_manager") {
|
|
// auto md_om = std::make_unique<MDSourceOM>(me->md_consumer);
|
|
// Component<MDSourceOM> c{std::move(md_om), &tr->thread};
|
|
// me->order_managers.emplace_back(std::move (c));
|
|
// continue;
|
|
// }
|
|
|
|
// if (c.name() == "gateway") {
|
|
// bts_assert_msg(
|
|
// c.arg_size() == 1,
|
|
// "Gateway component should have a single jetfix session "
|
|
// "name (arg: jf_session_name) in OrderManThreading"
|
|
// "configuration key");
|
|
// auto gw = std::make_unique<Gateway>(c.arg(0));
|
|
// Component<Gateway> c{std::move(gw), &tr->thread};
|
|
// me->gateways.emplace_back(std::move(c));
|
|
// continue;
|
|
// }
|
|
// }
|
|
|
|
// bts_assert_msg(me->service_bridge.component,
|
|
// "Missing service_bridge component in OrderManThreading "
|
|
// "configuration key");
|
|
// bts_assert_msg(
|
|
// me->storage.component,
|
|
// "Missing storage component in OrderManThreading configuration key");
|
|
// bts_assert_msg(
|
|
// me->order_managers.size(),
|
|
// "At least a order_manager component is required in OrderManThreading"
|
|
// "configuration key");
|
|
// bts_assert_msg(me->order_managers.size(),
|
|
// "At least a gateway component is required in "
|
|
// "OrderManThreading configuration key");
|
|
// }
|
|
// }
|
|
|
|
// } // namespace orderman_v2
|
|
// } // namespace bts
|