(ixbots) add new class to configure a bot to simplify passing options around

This commit is contained in:
Benjamin Sergeant
2020-05-12 19:08:16 -07:00
parent cc72494b63
commit 2e904801a0
18 changed files with 109 additions and 188 deletions

View File

@ -138,11 +138,12 @@ TEST_CASE("Cobra_to_sentry_bot", "[cobra_bots]")
std::thread publisherThread(runPublisher, config, channel);
std::string filter;
std::string position("$");
ix::CobraBotConfig cobraBotConfig;
cobraBotConfig.cobraConfig = config;
cobraBotConfig.channel = channel;
cobraBotConfig.runtime = 3; // Only run the bot for 3 seconds
cobraBotConfig.enableHeartbeat = false;
bool verbose = true;
bool enableHeartbeat = false;
int heartBeatTimeout = 60;
// FIXME: try to get this working with https instead of http
// to regress the TLS 1.3 OpenSSL bug
@ -157,18 +158,9 @@ TEST_CASE("Cobra_to_sentry_bot", "[cobra_bots]")
SentryClient sentryClient(dsn);
sentryClient.setTLSOptions(tlsOptionsClient);
// Only run the bot for 3 seconds
int runtime = 3;
int64_t sentCount = cobra_to_sentry_bot(config,
channel,
filter,
position,
int64_t sentCount = cobra_to_sentry_bot(cobraBotConfig,
sentryClient,
verbose,
enableHeartbeat,
heartBeatTimeout,
runtime);
verbose);
//
// We want at least 2 messages to be sent
//

View File

@ -87,14 +87,11 @@ TEST_CASE("Cobra_to_statsd_bot", "[cobra_bots]")
std::thread publisherThread(runPublisher, config, channel);
std::string filter;
std::string position("$");
bool verbose = true;
bool enableHeartbeat = false;
int heartBeatTimeout = 60;
// Only run the bot for 3 seconds
int runtime = 3;
ix::CobraBotConfig cobraBotConfig;
cobraBotConfig.cobraConfig = config;
cobraBotConfig.channel = channel;
cobraBotConfig.runtime = 3; // Only run the bot for 3 seconds
cobraBotConfig.enableHeartbeat = false;
std::string hostname("127.0.0.1");
// std::string hostname("www.google.com");
@ -113,19 +110,14 @@ TEST_CASE("Cobra_to_statsd_bot", "[cobra_bots]")
std::string fields("device.game\ndevice.os_name");
std::string gauge;
std::string timer;
bool verbose = true;
int64_t sentCount = ix::cobra_to_statsd_bot(config,
channel,
filter,
position,
int64_t sentCount = ix::cobra_to_statsd_bot(cobraBotConfig,
statsdClient,
fields,
gauge,
timer,
verbose,
enableHeartbeat,
heartBeatTimeout,
runtime);
verbose);
//
// We want at least 2 messages to be sent
//

View File

@ -85,27 +85,19 @@ TEST_CASE("Cobra_to_stdout_bot", "[cobra_bots]")
std::thread publisherThread(runPublisher, config, channel);
std::string filter;
std::string position("$");
ix::CobraBotConfig cobraBotConfig;
cobraBotConfig.cobraConfig = config;
cobraBotConfig.channel = channel;
cobraBotConfig.runtime = 3; // Only run the bot for 3 seconds
cobraBotConfig.enableHeartbeat = false;
bool quiet = false;
bool enableHeartbeat = false;
int heartBeatTimeout = 60;
// Only run the bot for 3 seconds
int runtime = 3;
// We could try to capture the output ... not sure how.
bool fluentd = true;
int64_t sentCount = ix::cobra_to_stdout_bot(config,
channel,
filter,
position,
int64_t sentCount = ix::cobra_to_stdout_bot(cobraBotConfig,
fluentd,
quiet,
enableHeartbeat,
heartBeatTimeout,
runtime);
quiet);
//
// We want at least 2 messages to be sent
//