From d4e1f71e3c52bcf0b5dbb651e5ca0261af1c0a7b Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Thu, 12 Mar 2020 12:30:58 -0700 Subject: [PATCH] (cobra2sentry bot) take a sentry client as input instead of a dsn --- ixbots/ixbots/IXCobraToSentryBot.cpp | 6 ++---- ixbots/ixbots/IXCobraToSentryBot.h | 3 ++- test/IXCobraToSentryBotTest.cpp | 5 ++++- ws/ws.cpp | 5 ++++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ixbots/ixbots/IXCobraToSentryBot.cpp b/ixbots/ixbots/IXCobraToSentryBot.cpp index 70851637..76069c12 100644 --- a/ixbots/ixbots/IXCobraToSentryBot.cpp +++ b/ixbots/ixbots/IXCobraToSentryBot.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -20,7 +19,7 @@ namespace ix int cobra_to_sentry_bot(const CobraConfig& config, const std::string& channel, const std::string& filter, - const std::string& dsn, + SentryClient& sentryClient, bool verbose, bool strict, size_t maxQueueSize, @@ -84,8 +83,7 @@ namespace ix std::thread t2(heartbeat); auto sentrySender = - [&queueManager, verbose, &errorSending, &sentCount, &stop, &throttled, &dsn] { - SentryClient sentryClient(dsn); + [&queueManager, verbose, &errorSending, &sentCount, &stop, &throttled, &sentryClient] { while (true) { diff --git a/ixbots/ixbots/IXCobraToSentryBot.h b/ixbots/ixbots/IXCobraToSentryBot.h index 83397ea6..6c4b128e 100644 --- a/ixbots/ixbots/IXCobraToSentryBot.h +++ b/ixbots/ixbots/IXCobraToSentryBot.h @@ -6,6 +6,7 @@ #pragma once #include +#include #include namespace ix @@ -13,7 +14,7 @@ namespace ix int cobra_to_sentry_bot(const CobraConfig& config, const std::string& channel, const std::string& filter, - const std::string& dsn, + SentryClient& sentryClient, bool verbose, bool strict, size_t maxQueueSize, diff --git a/test/IXCobraToSentryBotTest.cpp b/test/IXCobraToSentryBotTest.cpp index 3ea7e320..7e900197 100644 --- a/test/IXCobraToSentryBotTest.cpp +++ b/test/IXCobraToSentryBotTest.cpp @@ -16,6 +16,7 @@ #include #include #include +#include using namespace ix; @@ -157,13 +158,15 @@ TEST_CASE("Cobra_to_sentry_bot", "[foo]") oss << scheme << "xxxxxxx:yyyyyyy@localhost:" << sentryPort << "/1234567"; std::string dsn = oss.str(); + SentryClient sentryClient(dsn); + // Only run the bot for 3 seconds int runtime = 3; int sentCount = cobra_to_sentry_bot(config, channel, filter, - dsn, + sentryClient, verbose, strict, maxQueueSize, diff --git a/ws/ws.cpp b/ws/ws.cpp index 1fef4fd7..cc031994 100644 --- a/ws/ws.cpp +++ b/ws/ws.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -447,10 +448,12 @@ int main(int argc, char** argv) { bool enableHeartbeat = true; int runtime = -1; + ix::SentryClient sentryClient(dsn); + ret = ix::cobra_to_sentry_bot(cobraConfig, channel, filter, - dsn, + sentryClient, verbose, strict, maxQueueSize,