indent files

This commit is contained in:
Benjamin Sergeant 2020-03-20 17:00:18 -07:00
parent 1d6373335c
commit 5ce846f48b
12 changed files with 121 additions and 118 deletions

View File

@ -37,8 +37,7 @@ namespace ix
static OSStatus writeToSocket(SSLConnectionRef connection, const void* data, size_t* len); static OSStatus writeToSocket(SSLConnectionRef connection, const void* data, size_t* len);
static OSStatus readFromSocket(SSLConnectionRef connection, void* data, size_t* len); static OSStatus readFromSocket(SSLConnectionRef connection, void* data, size_t* len);
OSStatus tlsHandShake( OSStatus tlsHandShake(std::string& errMsg,
std::string& errMsg,
const CancellationRequest& isCancellationRequested); const CancellationRequest& isCancellationRequested);
SSLContextRef _sslContext; SSLContextRef _sslContext;

View File

@ -224,8 +224,7 @@ namespace ix
return true; return true;
} }
bool SocketOpenSSL::openSSLClientHandshake( bool SocketOpenSSL::openSSLClientHandshake(const std::string& host,
const std::string& host,
std::string& errMsg, std::string& errMsg,
const CancellationRequest& isCancellationRequested) const CancellationRequest& isCancellationRequested)
{ {

View File

@ -160,10 +160,8 @@ namespace ix
{ {
{ {
std::lock_guard<std::mutex> lock(_configMutex); std::lock_guard<std::mutex> lock(_configMutex);
_ws.configure(_perMessageDeflateOptions, _ws.configure(
_socketTLSOptions, _perMessageDeflateOptions, _socketTLSOptions, _enablePong, _pingIntervalSecs);
_enablePong,
_pingIntervalSecs);
} }
WebSocketHttpHeaders headers(_extraHeaders); WebSocketHttpHeaders headers(_extraHeaders);
@ -216,10 +214,8 @@ namespace ix
{ {
{ {
std::lock_guard<std::mutex> lock(_configMutex); std::lock_guard<std::mutex> lock(_configMutex);
_ws.configure(_perMessageDeflateOptions, _ws.configure(
_socketTLSOptions, _perMessageDeflateOptions, _socketTLSOptions, _enablePong, _pingIntervalSecs);
_enablePong,
_pingIntervalSecs);
} }
WebSocketInitResult status = _ws.connectToSocket(socket, timeoutSecs); WebSocketInitResult status = _ws.connectToSocket(socket, timeoutSecs);

View File

@ -251,15 +251,14 @@ namespace ix
// No timeout if state is not OPEN, otherwise computed // No timeout if state is not OPEN, otherwise computed
// pingIntervalOrTimeoutGCD (equals to -1 if no ping and no ping timeout are set) // pingIntervalOrTimeoutGCD (equals to -1 if no ping and no ping timeout are set)
int lastingTimeoutDelayInMs = int lastingTimeoutDelayInMs = (_readyState != ReadyState::OPEN) ? 0 : _pingIntervalSecs;
(_readyState != ReadyState::OPEN) ? 0 : _pingIntervalSecs;
if (_pingIntervalSecs > 0) if (_pingIntervalSecs > 0)
{ {
// compute lasting delay to wait for next ping / timeout, if at least one set // compute lasting delay to wait for next ping / timeout, if at least one set
auto now = std::chrono::steady_clock::now(); auto now = std::chrono::steady_clock::now();
lastingTimeoutDelayInMs = lastingTimeoutDelayInMs = (int) std::chrono::duration_cast<std::chrono::milliseconds>(
(int) std::chrono::duration_cast<std::chrono::milliseconds>(now - _lastSendPingTimePoint) now - _lastSendPingTimePoint)
.count(); .count();
} }

View File

@ -126,8 +126,10 @@ namespace
std::string filter; std::string filter;
std::string position("$"); std::string position("$");
_conn.subscribe( _conn.subscribe(channel,
channel, filter, position, [this](const Json::Value& msg, const std::string& /*position*/) { filter,
position,
[this](const Json::Value& msg, const std::string& /*position*/) {
spdlog::info("receive {}", msg.toStyledString()); spdlog::info("receive {}", msg.toStyledString());
if (!msg.isObject()) return; if (!msg.isObject()) return;
@ -149,7 +151,9 @@ namespace
_receivedQueue.push(msg); _receivedQueue.push(msg);
std::stringstream ss; std::stringstream ss;
ss << std::endl << msg_user << " > " << msg_text << std::endl << _user << " > "; ss << std::endl
<< msg_user << " > " << msg_text << std::endl
<< _user << " > ";
log(ss.str()); log(ss.str());
}); });
} }

View File

@ -77,8 +77,10 @@ namespace
std::string filter; std::string filter;
std::string position("$"); std::string position("$");
conn.subscribe( conn.subscribe(channel,
channel, filter, position, [](const Json::Value& msg, const std::string& /*position*/) { filter,
position,
[](const Json::Value& msg, const std::string& /*position*/) {
log(msg.toStyledString()); log(msg.toStyledString());
std::string id = msg["id"].asString(); std::string id = msg["id"].asString();

View File

@ -150,10 +150,7 @@ TEST_CASE("Cobra_to_sentry_bot", "[cobra_bots]")
// -> https://github.com/openssl/openssl/issues/7967 // -> https://github.com/openssl/openssl/issues/7967
// https://xxxxx:yyyyyy@sentry.io/1234567 // https://xxxxx:yyyyyy@sentry.io/1234567
std::stringstream oss; std::stringstream oss;
oss << getHttpScheme() oss << getHttpScheme() << "xxxxxxx:yyyyyyy@localhost:" << sentryPort << "/1234567";
<< "xxxxxxx:yyyyyyy@localhost:"
<< sentryPort
<< "/1234567";
std::string dsn = oss.str(); std::string dsn = oss.str();
SocketTLSOptions tlsOptionsClient = makeClientTLSOptions(); SocketTLSOptions tlsOptionsClient = makeClientTLSOptions();

View File

@ -237,9 +237,7 @@ namespace ix
std::string makeCobraEndpoint(int port, bool preferTLS) std::string makeCobraEndpoint(int port, bool preferTLS)
{ {
std::stringstream ss; std::stringstream ss;
ss << getWsScheme(preferTLS) ss << getWsScheme(preferTLS) << "localhost:" << port;
<< "localhost:"
<< port;
std::string endpoint = ss.str(); std::string endpoint = ss.str();
return endpoint; return endpoint;

View File

@ -9,8 +9,8 @@
#include "IXGetFreePort.h" #include "IXGetFreePort.h"
#include <iostream> #include <iostream>
#include <ixsnake/IXAppConfig.h> #include <ixsnake/IXAppConfig.h>
#include <ixwebsocket/IXWebSocketServer.h>
#include <ixwebsocket/IXSocketTLSOptions.h> #include <ixwebsocket/IXSocketTLSOptions.h>
#include <ixwebsocket/IXWebSocketServer.h>
#include <mutex> #include <mutex>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <sstream> #include <sstream>

View File

@ -171,9 +171,7 @@ int main(int argc, char** argv)
connectApp->add_option("--max_wait", connectApp->add_option("--max_wait",
maxWaitBetweenReconnectionRetries, maxWaitBetweenReconnectionRetries,
"Max Wait Time between reconnection retries"); "Max Wait Time between reconnection retries");
connectApp->add_option("--ping_interval", connectApp->add_option("--ping_interval", pingIntervalSecs, "Interval between sending pings");
pingIntervalSecs,
"Interval between sending pings");
connectApp->add_option("--subprotocol", subprotocol, "Subprotocol"); connectApp->add_option("--subprotocol", subprotocol, "Subprotocol");
addTLSOptions(connectApp); addTLSOptions(connectApp);
@ -475,7 +473,8 @@ int main(int argc, char** argv)
} }
else if (app.got_subcommand("cobra_metrics_to_redis")) else if (app.got_subcommand("cobra_metrics_to_redis"))
{ {
ret = ix::ws_cobra_metrics_to_redis(cobraConfig, channel, filter, position, hostname, redisPort); ret = ix::ws_cobra_metrics_to_redis(
cobraConfig, channel, filter, position, hostname, redisPort);
} }
else if (app.got_subcommand("snake")) else if (app.got_subcommand("snake"))
{ {

View File

@ -30,8 +30,7 @@ namespace ix
CobraMetricsPublisher cobraMetricsPublisher; CobraMetricsPublisher cobraMetricsPublisher;
cobraMetricsPublisher.enable(true); cobraMetricsPublisher.enable(true);
cobraMetricsPublisher.configure(config, cobraMetricsPublisher.configure(config, channel);
channel);
while (!cobraMetricsPublisher.isAuthenticated()) while (!cobraMetricsPublisher.isAuthenticated())
; ;

View File

@ -70,9 +70,15 @@ namespace ix
std::string subscriptionPosition(position); std::string subscriptionPosition(position);
conn.setEventCallback( conn.setEventCallback([&conn,
[&conn, &channel, &jsonWriter, &filter, &subscriptionPosition, &msgCount, &msgPerSeconds, &quiet, &fluentd]( &channel,
ix::CobraConnectionEventType eventType, &jsonWriter,
&filter,
&subscriptionPosition,
&msgCount,
&msgPerSeconds,
&quiet,
&fluentd](ix::CobraConnectionEventType eventType,
const std::string& errMsg, const std::string& errMsg,
const ix::WebSocketHttpHeaders& headers, const ix::WebSocketHttpHeaders& headers,
const std::string& subscriptionId, const std::string& subscriptionId,
@ -90,11 +96,16 @@ namespace ix
{ {
spdlog::info("Subscriber authenticated"); spdlog::info("Subscriber authenticated");
spdlog::info("Subscribing to {} at position {}", channel, subscriptionPosition); spdlog::info("Subscribing to {} at position {}", channel, subscriptionPosition);
conn.subscribe(channel, conn.subscribe(
channel,
filter, filter,
subscriptionPosition, subscriptionPosition,
[&jsonWriter, &quiet, &msgPerSeconds, &msgCount, &fluentd, &subscriptionPosition]( [&jsonWriter,
const Json::Value& msg, const std::string& position) { &quiet,
&msgPerSeconds,
&msgCount,
&fluentd,
&subscriptionPosition](const Json::Value& msg, const std::string& position) {
if (!quiet) if (!quiet)
{ {
writeToStdout(fluentd, jsonWriter, msg, position); writeToStdout(fluentd, jsonWriter, msg, position);