(cobra) IXCobraConfig struct has tlsOptions and per message deflate options
This commit is contained in:
parent
0a11132b07
commit
6a4d69afc5
@ -1,6 +1,10 @@
|
||||
# Changelog
|
||||
All changes to this project will be documented in this file.
|
||||
|
||||
## [8.2.1] - 2020-03-11
|
||||
|
||||
(cobra) IXCobraConfig struct has tlsOptions and per message deflate options
|
||||
|
||||
## [8.2.0] - 2020-03-11
|
||||
|
||||
(cobra) add IXCobraConfig struct to pass cobra config around
|
||||
|
@ -6,6 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ixwebsocket/IXWebSocketPerMessageDeflateOptions.h>
|
||||
#include <ixwebsocket/IXSocketTLSOptions.h>
|
||||
|
||||
namespace ix
|
||||
{
|
||||
struct CobraConfig
|
||||
@ -14,6 +17,8 @@ namespace ix
|
||||
std::string endpoint;
|
||||
std::string rolename;
|
||||
std::string rolesecret;
|
||||
WebSocketPerMessageDeflateOptions webSocketPerMessageDeflateOptions;
|
||||
SocketTLSOptions socketTLSOptions;
|
||||
|
||||
CobraConfig(const std::string& a = std::string(),
|
||||
const std::string& e = std::string(),
|
||||
@ -28,4 +33,3 @@ namespace ix
|
||||
}
|
||||
};
|
||||
} // namespace ix
|
||||
|
||||
|
@ -276,6 +276,16 @@ namespace ix
|
||||
_webSocket->setPingTimeout(3 * kPingIntervalSecs);
|
||||
}
|
||||
|
||||
void CobraConnection::configure(const ix::CobraConfig& config)
|
||||
{
|
||||
configure(config.appkey,
|
||||
config.endpoint,
|
||||
config.rolename,
|
||||
config.rolesecret,
|
||||
config.webSocketPerMessageDeflateOptions,
|
||||
config.socketTLSOptions);
|
||||
}
|
||||
|
||||
//
|
||||
// Handshake message schema.
|
||||
//
|
||||
|
@ -69,6 +69,8 @@ namespace ix
|
||||
const WebSocketPerMessageDeflateOptions& webSocketPerMessageDeflateOptions,
|
||||
const SocketTLSOptions& socketTLSOptions);
|
||||
|
||||
void configure(const ix::CobraConfig& config);
|
||||
|
||||
/// Set the traffic tracker callback
|
||||
static void setTrafficTrackerCallback(const TrafficTrackerCallback& callback);
|
||||
|
||||
|
@ -6,4 +6,4 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define IX_WEBSOCKET_VERSION "8.2.0"
|
||||
#define IX_WEBSOCKET_VERSION "8.2.1"
|
||||
|
19
ws/ws.cpp
19
ws/ws.cpp
@ -356,6 +356,10 @@ int main(int argc, char** argv)
|
||||
tlsOptions.caFile = "NONE";
|
||||
}
|
||||
|
||||
// Cobra config
|
||||
cobraConfig.webSocketPerMessageDeflateOptions = ix::WebSocketPerMessageDeflateOptions(true);
|
||||
cobraConfig.socketTLSOptions = tlsOptions;
|
||||
|
||||
int ret = 1;
|
||||
if (app.got_subcommand("transfer"))
|
||||
{
|
||||
@ -425,17 +429,17 @@ int main(int argc, char** argv)
|
||||
else if (app.got_subcommand("cobra_subscribe"))
|
||||
{
|
||||
ret = ix::ws_cobra_subscribe_main(
|
||||
cobraConfig, channel, filter, quiet, fluentd, tlsOptions);
|
||||
cobraConfig, channel, filter, quiet, fluentd);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_publish"))
|
||||
{
|
||||
ret = ix::ws_cobra_publish_main(
|
||||
cobraConfig, channel, path, tlsOptions);
|
||||
cobraConfig, channel, path);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_metrics_publish"))
|
||||
{
|
||||
ret = ix::ws_cobra_metrics_publish_main(
|
||||
cobraConfig, channel, path, stress, tlsOptions);
|
||||
cobraConfig, channel, path, stress);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_to_statsd"))
|
||||
{
|
||||
@ -446,8 +450,7 @@ int main(int argc, char** argv)
|
||||
statsdPort,
|
||||
prefix,
|
||||
fields,
|
||||
verbose,
|
||||
tlsOptions);
|
||||
verbose);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_to_sentry"))
|
||||
{
|
||||
@ -458,8 +461,7 @@ int main(int argc, char** argv)
|
||||
verbose,
|
||||
strict,
|
||||
jobs,
|
||||
maxQueueSize,
|
||||
tlsOptions);
|
||||
maxQueueSize);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_metrics_to_redis"))
|
||||
{
|
||||
@ -467,8 +469,7 @@ int main(int argc, char** argv)
|
||||
channel,
|
||||
filter,
|
||||
hostname,
|
||||
redisPort,
|
||||
tlsOptions);
|
||||
redisPort);
|
||||
}
|
||||
else if (app.got_subcommand("snake"))
|
||||
{
|
||||
|
18
ws/ws.h
18
ws/ws.h
@ -79,19 +79,16 @@ namespace ix
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
bool quiet,
|
||||
bool fluentd,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
bool fluentd);
|
||||
|
||||
int ws_cobra_publish_main(const ix::CobraConfig& appkey,
|
||||
const std::string& channel,
|
||||
const std::string& path,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
const std::string& path);
|
||||
|
||||
int ws_cobra_metrics_publish_main(const ix::CobraConfig& config,
|
||||
const std::string& channel,
|
||||
const std::string& path,
|
||||
bool stress,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
bool stress);
|
||||
|
||||
int ws_cobra_to_statsd_main(const ix::CobraConfig& config,
|
||||
const std::string& channel,
|
||||
@ -100,8 +97,7 @@ namespace ix
|
||||
int port,
|
||||
const std::string& prefix,
|
||||
const std::string& fields,
|
||||
bool verbose,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
bool verbose);
|
||||
|
||||
int ws_cobra_to_sentry_main(const ix::CobraConfig& config,
|
||||
const std::string& channel,
|
||||
@ -110,15 +106,13 @@ namespace ix
|
||||
bool verbose,
|
||||
bool strict,
|
||||
int jobs,
|
||||
size_t maxQueueSize,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
size_t maxQueueSize);
|
||||
|
||||
int ws_cobra_metrics_to_redis(const ix::CobraConfig& config,
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
const std::string& host,
|
||||
int port,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
int port);
|
||||
|
||||
int ws_snake_main(int port,
|
||||
const std::string& hostname,
|
||||
|
@ -18,8 +18,7 @@ namespace ix
|
||||
int ws_cobra_metrics_publish_main(const ix::CobraConfig& config,
|
||||
const std::string& channel,
|
||||
const std::string& path,
|
||||
bool stress,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
bool stress)
|
||||
{
|
||||
std::atomic<int> sentMessages(0);
|
||||
std::atomic<int> ackedMessages(0);
|
||||
@ -34,7 +33,7 @@ namespace ix
|
||||
|
||||
bool enablePerMessageDeflate = true;
|
||||
cobraMetricsPublisher.configure(
|
||||
config.appkey, config.endpoint, channel, config.rolename, config.rolesecret, enablePerMessageDeflate, tlsOptions);
|
||||
config.appkey, config.endpoint, channel, config.rolename, config.rolesecret, enablePerMessageDeflate, config.socketTLSOptions);
|
||||
|
||||
while (!cobraMetricsPublisher.isAuthenticated())
|
||||
;
|
||||
|
@ -21,16 +21,10 @@ namespace ix
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
const std::string& host,
|
||||
int port,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
int port)
|
||||
{
|
||||
ix::CobraConnection conn;
|
||||
conn.configure(config.appkey,
|
||||
config.endpoint,
|
||||
config.rolename,
|
||||
config.rolesecret,
|
||||
ix::WebSocketPerMessageDeflateOptions(true),
|
||||
tlsOptions);
|
||||
conn.configure(config);
|
||||
conn.connect();
|
||||
|
||||
// Display incoming messages
|
||||
|
@ -18,8 +18,7 @@ namespace ix
|
||||
{
|
||||
int ws_cobra_publish_main(const ix::CobraConfig& config,
|
||||
const std::string& channel,
|
||||
const std::string& path,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
const std::string& path)
|
||||
{
|
||||
std::ifstream f(path);
|
||||
std::string str((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
||||
@ -33,12 +32,7 @@ namespace ix
|
||||
}
|
||||
|
||||
ix::CobraConnection conn;
|
||||
conn.configure(config.appkey,
|
||||
config.endpoint,
|
||||
config.rolename,
|
||||
config.rolesecret,
|
||||
ix::WebSocketPerMessageDeflateOptions(true),
|
||||
tlsOptions);
|
||||
conn.configure(config);
|
||||
|
||||
// Display incoming messages
|
||||
std::atomic<bool> authenticated(false);
|
||||
|
@ -35,16 +35,10 @@ namespace ix
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
bool quiet,
|
||||
bool fluentd,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
bool fluentd)
|
||||
{
|
||||
ix::CobraConnection conn;
|
||||
conn.configure(config.appkey,
|
||||
config.endpoint,
|
||||
config.rolename,
|
||||
config.rolesecret,
|
||||
ix::WebSocketPerMessageDeflateOptions(true),
|
||||
tlsOptions);
|
||||
conn.configure(config);
|
||||
conn.connect();
|
||||
|
||||
Json::FastWriter jsonWriter;
|
||||
|
@ -99,16 +99,10 @@ namespace ix
|
||||
bool verbose,
|
||||
bool strict,
|
||||
int jobs,
|
||||
size_t maxQueueSize,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
size_t maxQueueSize)
|
||||
{
|
||||
ix::CobraConnection conn;
|
||||
conn.configure(config.appkey,
|
||||
config.endpoint,
|
||||
config.rolename,
|
||||
config.rolesecret,
|
||||
ix::WebSocketPerMessageDeflateOptions(true),
|
||||
tlsOptions);
|
||||
conn.configure(config);
|
||||
conn.connect();
|
||||
|
||||
Json::FastWriter jsonWriter;
|
||||
|
@ -116,16 +116,10 @@ namespace ix
|
||||
int port,
|
||||
const std::string& prefix,
|
||||
const std::string& fields,
|
||||
bool verbose,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
bool verbose)
|
||||
{
|
||||
ix::CobraConnection conn;
|
||||
conn.configure(config.appkey,
|
||||
config.endpoint,
|
||||
config.rolename,
|
||||
config.rolesecret,
|
||||
ix::WebSocketPerMessageDeflateOptions(true),
|
||||
tlsOptions);
|
||||
conn.configure(config);
|
||||
conn.connect();
|
||||
|
||||
auto tokens = parseFields(fields);
|
||||
|
Loading…
x
Reference in New Issue
Block a user