(cobra client) can subscribe with a position
This commit is contained in:
12
ws/ws.cpp
12
ws/ws.cpp
@@ -65,6 +65,7 @@ int main(int argc, char** argv)
|
||||
std::string pidfile;
|
||||
std::string channel;
|
||||
std::string filter;
|
||||
std::string position;
|
||||
std::string message;
|
||||
std::string password;
|
||||
std::string prefix("ws.test.v0");
|
||||
@@ -229,6 +230,7 @@ int main(int argc, char** argv)
|
||||
cobraSubscribeApp->add_option("--channel", channel, "Channel")->required();
|
||||
cobraSubscribeApp->add_option("--pidfile", pidfile, "Pid file");
|
||||
cobraSubscribeApp->add_option("--filter", filter, "Stream SQL Filter");
|
||||
cobraSubscribeApp->add_option("--position", position, "Stream position");
|
||||
cobraSubscribeApp->add_flag("-q", quiet, "Quiet / only display stats");
|
||||
cobraSubscribeApp->add_flag("--fluentd", fluentd, "Write fluentd prefix");
|
||||
addTLSOptions(cobraSubscribeApp);
|
||||
@@ -263,6 +265,7 @@ int main(int argc, char** argv)
|
||||
cobra2statsd->add_flag("-v", verbose, "Verbose");
|
||||
cobra2statsd->add_option("--pidfile", pidfile, "Pid file");
|
||||
cobra2statsd->add_option("--filter", filter, "Stream SQL Filter");
|
||||
cobra2statsd->add_option("--position", position, "Stream position");
|
||||
addTLSOptions(cobra2statsd);
|
||||
addCobraConfig(cobra2statsd);
|
||||
|
||||
@@ -276,6 +279,7 @@ int main(int argc, char** argv)
|
||||
cobra2sentry->add_flag("-s", strict, "Strict mode. Error out when sending to sentry fails");
|
||||
cobra2sentry->add_option("--pidfile", pidfile, "Pid file");
|
||||
cobra2sentry->add_option("--filter", filter, "Stream SQL Filter");
|
||||
cobra2sentry->add_option("--position", position, "Stream position");
|
||||
addTLSOptions(cobra2sentry);
|
||||
addCobraConfig(cobra2sentry);
|
||||
|
||||
@@ -284,6 +288,7 @@ int main(int argc, char** argv)
|
||||
cobra2redisApp->add_option("channel", channel, "Channel")->required();
|
||||
cobra2redisApp->add_option("--pidfile", pidfile, "Pid file");
|
||||
cobra2redisApp->add_option("--filter", filter, "Stream SQL Filter");
|
||||
cobra2redisApp->add_option("--position", position, "Stream position");
|
||||
cobra2redisApp->add_option("--hostname", hostname, "Redis hostname");
|
||||
cobra2redisApp->add_option("--port", redisPort, "Redis port");
|
||||
cobra2redisApp->add_flag("-q", quiet, "Quiet / only display stats");
|
||||
@@ -429,7 +434,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
else if (app.got_subcommand("cobra_subscribe"))
|
||||
{
|
||||
ret = ix::ws_cobra_subscribe_main(cobraConfig, channel, filter, quiet, fluentd);
|
||||
ret = ix::ws_cobra_subscribe_main(cobraConfig, channel, filter, position, quiet, fluentd);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_publish"))
|
||||
{
|
||||
@@ -442,7 +447,7 @@ int main(int argc, char** argv)
|
||||
else if (app.got_subcommand("cobra_to_statsd"))
|
||||
{
|
||||
ret = ix::cobra_to_statsd_bot(
|
||||
cobraConfig, channel, filter, hostname, statsdPort, prefix, fields, verbose);
|
||||
cobraConfig, channel, filter, position, hostname, statsdPort, prefix, fields, verbose);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_to_sentry"))
|
||||
{
|
||||
@@ -453,6 +458,7 @@ int main(int argc, char** argv)
|
||||
ret = ix::cobra_to_sentry_bot(cobraConfig,
|
||||
channel,
|
||||
filter,
|
||||
position,
|
||||
sentryClient,
|
||||
verbose,
|
||||
strict,
|
||||
@@ -462,7 +468,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
else if (app.got_subcommand("cobra_metrics_to_redis"))
|
||||
{
|
||||
ret = ix::ws_cobra_metrics_to_redis(cobraConfig, channel, filter, hostname, redisPort);
|
||||
ret = ix::ws_cobra_metrics_to_redis(cobraConfig, channel, filter, position, hostname, redisPort);
|
||||
}
|
||||
else if (app.got_subcommand("snake"))
|
||||
{
|
||||
|
2
ws/ws.h
2
ws/ws.h
@@ -78,6 +78,7 @@ namespace ix
|
||||
int ws_cobra_subscribe_main(const ix::CobraConfig& config,
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
const std::string& position,
|
||||
bool quiet,
|
||||
bool fluentd);
|
||||
|
||||
@@ -93,6 +94,7 @@ namespace ix
|
||||
int ws_cobra_metrics_to_redis(const ix::CobraConfig& config,
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
const std::string& position,
|
||||
const std::string& host,
|
||||
int port);
|
||||
|
||||
|
@@ -20,6 +20,7 @@ namespace ix
|
||||
int ws_cobra_metrics_to_redis(const ix::CobraConfig& config,
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
const std::string& position,
|
||||
const std::string& host,
|
||||
int port)
|
||||
{
|
||||
@@ -100,6 +101,7 @@ namespace ix
|
||||
conn.setEventCallback([&conn,
|
||||
&channel,
|
||||
&filter,
|
||||
&position,
|
||||
&msgCount,
|
||||
&msgPerSeconds,
|
||||
&conditionVariableMutex,
|
||||
@@ -125,6 +127,7 @@ namespace ix
|
||||
conn.subscribe(
|
||||
channel,
|
||||
filter,
|
||||
position,
|
||||
[&msgPerSeconds, &msgCount, &conditionVariableMutex, &condition, &queue](
|
||||
const Json::Value& msg, const std::string& /*position*/) {
|
||||
{
|
||||
|
@@ -41,6 +41,7 @@ namespace ix
|
||||
int ws_cobra_subscribe_main(const ix::CobraConfig& config,
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
const std::string& position,
|
||||
bool quiet,
|
||||
bool fluentd)
|
||||
{
|
||||
@@ -68,7 +69,7 @@ namespace ix
|
||||
std::thread t(timer);
|
||||
|
||||
conn.setEventCallback(
|
||||
[&conn, &channel, &jsonWriter, &filter, &msgCount, &msgPerSeconds, &quiet, &fluentd](
|
||||
[&conn, &channel, &jsonWriter, &filter, &position, &msgCount, &msgPerSeconds, &quiet, &fluentd](
|
||||
ix::CobraConnectionEventType eventType,
|
||||
const std::string& errMsg,
|
||||
const ix::WebSocketHttpHeaders& headers,
|
||||
@@ -88,6 +89,7 @@ namespace ix
|
||||
spdlog::info("Subscriber authenticated");
|
||||
conn.subscribe(channel,
|
||||
filter,
|
||||
position,
|
||||
[&jsonWriter, &quiet, &msgPerSeconds, &msgCount, &fluentd](
|
||||
const Json::Value& msg, const std::string& position) {
|
||||
if (!quiet)
|
||||
|
Reference in New Issue
Block a user