some minor tweaks to the connection timeout, docs

This commit is contained in:
Doug Hoyte
2024-10-18 16:35:43 -04:00
parent 17864d69fc
commit 4b16dc1aa7
2 changed files with 16 additions and 14 deletions

View File

@ -18,6 +18,8 @@ The config file must have a section `streams`. Within that, you may have as many
### Example ### Example
connectionTimeout = 20
streams { streams {
## Stream down events from our friend relays ## Stream down events from our friend relays

View File

@ -218,7 +218,8 @@ struct Router {
}; };
std::string routerConfigFile; std::string routerConfigFile;
uint64_t connectionTimeoutUs = 20'000'000; const uint64_t defaultConnectionTimeoutUs = 20'000'000;
uint64_t connectionTimeoutUs = 0;
WriterPipeline writer; WriterPipeline writer;
Decompressor decomp; Decompressor decomp;
@ -293,19 +294,6 @@ struct Router {
void reconcileConfig() { void reconcileConfig() {
LI << "Loading router config file: " << routerConfigFile; LI << "Loading router config file: " << routerConfigFile;
try {
auto routerConfig = loadRawTaoConfig(routerConfigFile);
if (routerConfig.find("timeout")) {
connectionTimeoutUs = stoi(routerConfig.at("timeout").get_string()) * 1'000'000;
LI << "Using configured timeout (seconds): " << (connectionTimeoutUs / 1'000'000);
} else {
LI << "Using default timeout (seconds): " << connectionTimeoutUs / 1'000'000;
}
} catch (std::exception &e) {
LE << "Failed to parse router timeout in config: " << e.what();
}
try { try {
auto routerConfig = loadRawTaoConfig(routerConfigFile); auto routerConfig = loadRawTaoConfig(routerConfigFile);
@ -326,6 +314,18 @@ struct Router {
for (const auto &[groupName, spec] : routerConfig.at("streams").get_object()) unneededGroups.erase(groupName); for (const auto &[groupName, spec] : routerConfig.at("streams").get_object()) unneededGroups.erase(groupName);
for (const auto &groupName : unneededGroups) streamGroups.erase(groupName); for (const auto &groupName : unneededGroups) streamGroups.erase(groupName);
} }
// connectionTimeout
uint64_t newTimeoutUs = defaultConnectionTimeoutUs;
if (routerConfig.get_object().contains("connectionTimeout")) {
newTimeoutUs = routerConfig.at("connectionTimeout").get_unsigned() * 1'000'000;
}
if (connectionTimeoutUs != newTimeoutUs) {
connectionTimeoutUs = newTimeoutUs;
LI << "Using connection timeout: " << (connectionTimeoutUs / 1'000'000) << " seconds";
}
} catch (std::exception &e) { } catch (std::exception &e) {
LE << "Failed to parse router config: " << e.what(); LE << "Failed to parse router config: " << e.what();
if (!firstConfigLoadSuccess) ::exit(1); if (!firstConfigLoadSuccess) ::exit(1);