fix: Init quickbus node cfg w/ proper defaults
This commit is contained in:
1 parent
4058a98290
commit
b7fae8a6f5
10 files changed
+65
-42
No files matched your search
@@ -106,7 +106,8 @@ namespace bts.test {
|
||||
port = (uint)((IPEndPoint)listener.LocalEndpoint).Port;
|
||||
listener.Stop();
|
||||
}
|
||||
var cfg = new config.QuickbusNodeCfg() { MyPort = port };
|
||||
var cfg = mbts.config.Configuration.get<config.QuickbusCfg>().Node;
|
||||
cfg.MyPort = port;
|
||||
var stream = new MemoryStream();
|
||||
ProtoBuf.Serializer.Serialize(stream, cfg);
|
||||
IntPtr qbus = ApiNativeMethods.api_create_quickbus(stream.ToArray(), stream.Length);
|
||||
|
||||
@@ -21,18 +21,12 @@ namespace bts {
|
||||
namespace api {
|
||||
|
||||
config::QuickbusNodeCfg get_client_node_cfg() {
|
||||
auto cfg = config::get<config::QuickbusCfg>();
|
||||
config::QuickbusNodeCfg node_cfg;
|
||||
node_cfg.set_reconnect_period_secs(cfg.reconnect_period_secs());
|
||||
node_cfg.set_hb_period_msecs(cfg.hb_period_msecs());
|
||||
node_cfg.set_max_missed_hbs(cfg.max_missed_hbs());
|
||||
node_cfg.set_parent_host(
|
||||
cfg.qbus_host().empty() ? config::get<config::SystemConfig>().config_ip()
|
||||
: cfg.qbus_host());
|
||||
node_cfg.set_parent_port(
|
||||
cfg.qbus_port() == 0 ? config::get<config::Ports>().qbus_port()
|
||||
: cfg.qbus_port());
|
||||
node_cfg.set_my_port(0);
|
||||
const auto node_cfg = config::get<config::QuickbusCfg>().client();
|
||||
// Assert reasonable values
|
||||
bts_assert(node_cfg.hb_period_msecs() > 0);
|
||||
bts_assert(node_cfg.reconnect_period_secs() > 0);
|
||||
bts_assert(node_cfg.max_missed_hbs() > 0);
|
||||
bts_assert(node_cfg.my_port() == 0);
|
||||
return node_cfg;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
QuickbusCfg {
|
||||
value {
|
||||
node {
|
||||
reconnect_period_secs: 5
|
||||
hb_period_msecs: 15000
|
||||
max_missed_hbs: 3
|
||||
parent_host: ""
|
||||
parent_port: 0
|
||||
my_port: 0
|
||||
}
|
||||
client {
|
||||
reconnect_period_secs: 5
|
||||
hb_period_msecs: 15000
|
||||
max_missed_hbs: 3
|
||||
parent_host: @SystemConfig.config_ip
|
||||
parent_port: @Ports.qbus_port
|
||||
my_port: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RPCConfig {
|
||||
value {
|
||||
rpc_connect_timeout_seconds: 10
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,8 @@ message QuickbusNodeCfg {
|
||||
}
|
||||
|
||||
message QuickbusCfg {
|
||||
uint32 reconnect_period_secs = 1;
|
||||
string qbus_host = 2;
|
||||
uint32 qbus_port = 3;
|
||||
uint32 hb_period_msecs = 5;
|
||||
uint32 max_missed_hbs = 6;
|
||||
QuickbusNodeCfg node = 1;
|
||||
QuickbusNodeCfg client = 2;
|
||||
}
|
||||
|
||||
message RPCConfig {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Quickbus.h"
|
||||
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/quickbus_cfg.pb.h"
|
||||
#include "lib/os/os.h"
|
||||
#include "lib/quickbus/network/QBConnectionManager.h"
|
||||
@@ -27,7 +28,7 @@ struct Quickbus::PImpl {
|
||||
};
|
||||
|
||||
Quickbus::Quickbus(ThreadOptions options)
|
||||
: me(new PImpl(config::QuickbusNodeCfg(), options)) {
|
||||
: me(new PImpl(config::get<config::QuickbusCfg>().node(), options)) {
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@ struct QBConnection::PImpl {
|
||||
remote_desc(remote_endpoint_description(socket)), cfg(cfg),
|
||||
last_received_ts(datetime::now()), last_sent_ts(datetime::now()),
|
||||
hb_timer(GET_IO_SERVICE(socket)) {
|
||||
// Assert reasonable values
|
||||
bts_assert(cfg.hb_period_msecs() > 0);
|
||||
bts_assert(cfg.max_missed_hbs() > 0);
|
||||
bts_assert(cfg.reconnect_period_secs() > 0);
|
||||
write_buffer.reserve(100 * 1024);
|
||||
read_buffer.reserve(100 * 1024);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "catch/catch.hpp"
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/os/os.h"
|
||||
#include "lib/quickbus/quickbus.h"
|
||||
#include "lib/utils/bts_chrono.h"
|
||||
@@ -14,11 +15,11 @@ TEST_CASE("Quickbus Pubsub Tests", "[quickbus]") {
|
||||
auto parent_port = os::get_random_port();
|
||||
|
||||
SECTION("smoke") {
|
||||
config::QuickbusNodeCfg pcfg;
|
||||
auto pcfg = config::get<config::QuickbusCfg>().node();
|
||||
pcfg.set_my_port(parent_port);
|
||||
Quickbus parent(pcfg);
|
||||
|
||||
config::QuickbusNodeCfg ccfg;
|
||||
auto ccfg = config::get<config::QuickbusCfg>().node();
|
||||
ccfg.set_parent_host("127.0.0.1");
|
||||
ccfg.set_reconnect_period_secs(1);
|
||||
ccfg.set_parent_port(parent_port);
|
||||
@@ -47,11 +48,11 @@ TEST_CASE("Quickbus Pubsub Tests", "[quickbus]") {
|
||||
}
|
||||
|
||||
SECTION("quickbus_late_join_works") {
|
||||
config::QuickbusNodeCfg pcfg;
|
||||
auto pcfg = config::get<config::QuickbusCfg>().node();
|
||||
pcfg.set_my_port(parent_port);
|
||||
Quickbus parent(pcfg);
|
||||
|
||||
config::QuickbusNodeCfg ccfg;
|
||||
auto ccfg = config::get<config::QuickbusCfg>().node();
|
||||
ccfg.set_parent_host("127.0.0.1");
|
||||
ccfg.set_reconnect_period_secs(1);
|
||||
ccfg.set_parent_port(parent_port);
|
||||
@@ -87,11 +88,11 @@ TEST_CASE("Quickbus Pubsub Tests", "[quickbus]") {
|
||||
}
|
||||
|
||||
SECTION("subscriber_late_join_work") {
|
||||
config::QuickbusNodeCfg pcfg;
|
||||
auto pcfg = config::get<config::QuickbusCfg>().node();
|
||||
pcfg.set_my_port(parent_port);
|
||||
Quickbus parent(pcfg);
|
||||
|
||||
config::QuickbusNodeCfg ccfg;
|
||||
auto ccfg = config::get<config::QuickbusCfg>().node();
|
||||
ccfg.set_parent_host("127.0.0.1");
|
||||
ccfg.set_reconnect_period_secs(1);
|
||||
ccfg.set_parent_port(parent_port);
|
||||
@@ -125,11 +126,11 @@ TEST_CASE("Quickbus Pubsub Tests", "[quickbus]") {
|
||||
}
|
||||
|
||||
SECTION("filtering_work") {
|
||||
config::QuickbusNodeCfg pcfg;
|
||||
auto pcfg = config::get<config::QuickbusCfg>().node();
|
||||
pcfg.set_my_port(parent_port);
|
||||
Quickbus parent(pcfg);
|
||||
|
||||
config::QuickbusNodeCfg ccfg;
|
||||
auto ccfg = config::get<config::QuickbusCfg>().node();
|
||||
ccfg.set_parent_host("127.0.0.1");
|
||||
ccfg.set_reconnect_period_secs(1);
|
||||
ccfg.set_parent_port(parent_port);
|
||||
@@ -156,11 +157,11 @@ TEST_CASE("Quickbus Pubsub Tests", "[quickbus]") {
|
||||
}
|
||||
|
||||
SECTION("unsubscribe_work") {
|
||||
config::QuickbusNodeCfg pcfg;
|
||||
auto pcfg = config::get<config::QuickbusCfg>().node();
|
||||
pcfg.set_my_port(parent_port);
|
||||
Quickbus parent(pcfg);
|
||||
|
||||
config::QuickbusNodeCfg ccfg;
|
||||
auto ccfg = config::get<config::QuickbusCfg>().node();
|
||||
ccfg.set_parent_host("127.0.0.1");
|
||||
ccfg.set_reconnect_period_secs(1);
|
||||
ccfg.set_parent_port(parent_port);
|
||||
@@ -195,7 +196,7 @@ TEST_CASE("Quickbus Pubsub Tests", "[quickbus]") {
|
||||
}
|
||||
|
||||
SECTION("force_singleton_topics_work") {
|
||||
Quickbus qb{config::QuickbusNodeCfg()};
|
||||
Quickbus qb{config::get<config::QuickbusCfg>().node()};
|
||||
|
||||
TablePublisher pub1(qb, Topic("A"));
|
||||
TablePublisher pub2(qb, Topic("A"));
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "catch/catch.hpp"
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/quickbus_cfg.pb.h"
|
||||
#include "lib/os/os.h"
|
||||
#include "lib/quickbus/quickbus.h"
|
||||
#include "lib/utils/TimeStamp.h"
|
||||
@@ -45,7 +47,7 @@ TEST_CASE("Quickbus RPC Tests", "[quickbus]") {
|
||||
auto qb_port = os::get_random_port();
|
||||
|
||||
SECTION("smoke") {
|
||||
config::QuickbusNodeCfg cfg;
|
||||
auto cfg = config::get<config::QuickbusCfg>().node();
|
||||
cfg.set_my_port(qb_port);
|
||||
Quickbus qb(cfg);
|
||||
auto sn = RPCServiceName("test");
|
||||
@@ -72,7 +74,7 @@ TEST_CASE("Quickbus RPC Tests", "[quickbus]") {
|
||||
}
|
||||
|
||||
SECTION("no_server_is_reported") {
|
||||
config::QuickbusNodeCfg cfg;
|
||||
auto cfg = config::get<config::QuickbusCfg>().node();
|
||||
cfg.set_my_port(qb_port);
|
||||
Quickbus qb(cfg);
|
||||
auto sn = RPCServiceName("test");
|
||||
@@ -93,7 +95,7 @@ TEST_CASE("Quickbus RPC Tests", "[quickbus]") {
|
||||
}
|
||||
|
||||
SECTION("failure_with_in_flight_is_reported") {
|
||||
config::QuickbusNodeCfg cfg;
|
||||
auto cfg = config::get<config::QuickbusCfg>().node();
|
||||
cfg.set_my_port(qb_port);
|
||||
Quickbus qb(cfg);
|
||||
auto sn = RPCServiceName("test");
|
||||
@@ -118,7 +120,7 @@ TEST_CASE("Quickbus RPC Tests", "[quickbus]") {
|
||||
}
|
||||
|
||||
SECTION("failure_with_no_in_flight_is_hidden") {
|
||||
config::QuickbusNodeCfg cfg;
|
||||
auto cfg = config::get<config::QuickbusCfg>().node();
|
||||
cfg.set_my_port(qb_port);
|
||||
Quickbus qb(cfg);
|
||||
auto sn = RPCServiceName("test");
|
||||
@@ -168,7 +170,7 @@ TEST_CASE("Quickbus RPC Tests", "[quickbus]") {
|
||||
}
|
||||
|
||||
SECTION("replies_are_matched_to_requests") {
|
||||
config::QuickbusNodeCfg cfg;
|
||||
auto cfg = config::get<config::QuickbusCfg>().node();
|
||||
cfg.set_my_port(qb_port);
|
||||
Quickbus qb(cfg);
|
||||
auto sn = RPCServiceName("test");
|
||||
@@ -205,7 +207,7 @@ TEST_CASE("Quickbus RPC Tests", "[quickbus]") {
|
||||
}
|
||||
|
||||
SECTION("replies_are_matched_to_clients") {
|
||||
config::QuickbusNodeCfg cfg;
|
||||
auto cfg = config::get<config::QuickbusCfg>().node();
|
||||
cfg.set_my_port(qb_port);
|
||||
Quickbus qb(cfg);
|
||||
auto sn = RPCServiceName("test");
|
||||
@@ -247,7 +249,7 @@ TEST_CASE("Quickbus RPC Tests", "[quickbus]") {
|
||||
}
|
||||
|
||||
SECTION("rpc_latency_same_qb") {
|
||||
config::QuickbusNodeCfg cfg;
|
||||
auto cfg = config::get<config::QuickbusCfg>().node();
|
||||
cfg.set_my_port(qb_port);
|
||||
Quickbus qb(cfg);
|
||||
auto sn = RPCServiceName("test");
|
||||
|
||||
@@ -50,10 +50,7 @@ static void execute() {
|
||||
"------------------------------------ Sparkd launched "
|
||||
"--------------------------------");
|
||||
|
||||
config::QuickbusNodeCfg qb_cfg;
|
||||
qb_cfg.set_reconnect_period_secs(5);
|
||||
qb_cfg.set_hb_period_msecs(15000);
|
||||
qb_cfg.set_max_missed_hbs(3);
|
||||
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(
|
||||
|
||||
@@ -41,7 +41,7 @@ Web::Web()
|
||||
_args(new Web::Args()) {
|
||||
add_flag("--md", _args->md, "Start market data");
|
||||
callback([&] {
|
||||
config::QuickbusNodeCfg qb_cfg;
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user