From adf6aa1d6cb1e281571eedaa70626108406522c5 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Thu, 12 Mar 2020 12:24:25 -0700 Subject: [PATCH] (cobra2sentry bot) remove the jobs option passed to ws, and only use one sentry sender --- ixbots/ixbots/IXCobraToSentryBot.cpp | 21 ++++++--------------- ixbots/ixbots/IXCobraToSentryBot.h | 1 - test/IXCobraToSentryBotTest.cpp | 2 -- ws/ws.cpp | 3 --- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/ixbots/ixbots/IXCobraToSentryBot.cpp b/ixbots/ixbots/IXCobraToSentryBot.cpp index 7c4b2fb3..70851637 100644 --- a/ixbots/ixbots/IXCobraToSentryBot.cpp +++ b/ixbots/ixbots/IXCobraToSentryBot.cpp @@ -23,7 +23,6 @@ namespace ix const std::string& dsn, bool verbose, bool strict, - int jobs, size_t maxQueueSize, bool enableHeartbeat, int runtime) @@ -92,7 +91,7 @@ namespace ix { Json::Value msg = queueManager.pop(); - if (stop) return; + if (stop) break; if (msg.isNull()) continue; auto ret = sentryClient.send(msg, verbose); @@ -165,17 +164,13 @@ namespace ix ++sentCount; } - if (stop) return; + if (stop) break; } + + spdlog::info("sentrySender thread done"); }; - // Create a thread pool - spdlog::info("Starting {} sentry sender jobs", jobs); - std::vector pool; - for (int i = 0; i < jobs; i++) - { - pool.push_back(std::thread(sentrySender)); - } + std::thread t3(sentrySender); conn.setEventCallback([&conn, &channel, @@ -280,11 +275,7 @@ namespace ix if (t2.joinable()) t2.join(); spdlog::info("heartbeat thread done"); - for (int i = 0; i < jobs; i++) - { - spdlog::info("joining thread {}", i); - pool[i].join(); - } + t3.join(); return (strict && errorSending) ? -1 : (int) sentCount; } diff --git a/ixbots/ixbots/IXCobraToSentryBot.h b/ixbots/ixbots/IXCobraToSentryBot.h index c9ebc7a3..83397ea6 100644 --- a/ixbots/ixbots/IXCobraToSentryBot.h +++ b/ixbots/ixbots/IXCobraToSentryBot.h @@ -16,7 +16,6 @@ namespace ix const std::string& dsn, bool verbose, bool strict, - int jobs, size_t maxQueueSize, bool enableHeartbeat, int runtime); diff --git a/test/IXCobraToSentryBotTest.cpp b/test/IXCobraToSentryBotTest.cpp index 6c5c9f1f..3ea7e320 100644 --- a/test/IXCobraToSentryBotTest.cpp +++ b/test/IXCobraToSentryBotTest.cpp @@ -147,7 +147,6 @@ TEST_CASE("Cobra_to_sentry_bot", "[foo]") std::string filter; bool verbose = true; bool strict = true; - int jobs = 1; size_t maxQueueSize = 10; bool enableHeartbeat = false; @@ -167,7 +166,6 @@ TEST_CASE("Cobra_to_sentry_bot", "[foo]") dsn, verbose, strict, - jobs, maxQueueSize, enableHeartbeat, runtime); diff --git a/ws/ws.cpp b/ws/ws.cpp index e108aaae..1fef4fd7 100644 --- a/ws/ws.cpp +++ b/ws/ws.cpp @@ -108,7 +108,6 @@ int main(int argc, char** argv) int maxRedirects = 5; int delayMs = -1; int count = 1; - int jobs = 4; uint32_t maxWaitBetweenReconnectionRetries; size_t maxQueueSize = 100; @@ -268,7 +267,6 @@ int main(int argc, char** argv) CLI::App* cobra2sentry = app.add_subcommand("cobra_to_sentry", "Cobra metrics to sentry"); cobra2sentry->add_option("--dsn", dsn, "Sentry DSN"); - cobra2sentry->add_option("--jobs", jobs, "Number of thread sending events to Sentry"); cobra2sentry->add_option("--queue_size", maxQueueSize, "Size of the queue to hold messages before they are sent to Sentry"); @@ -455,7 +453,6 @@ int main(int argc, char** argv) dsn, verbose, strict, - jobs, maxQueueSize, enableHeartbeat, runtime);