Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
1d3db5f75b | |||
296762ce06 | |||
e465f7af52 | |||
f8bf1fe7cd | |||
cfa5718e40 | |||
40c619c1ec | |||
22b02e0e5c | |||
738a3bf1c5 | |||
598fb071e3 | |||
686aface26 | |||
3073dd3f06 | |||
68c64f3f69 |
@ -1 +1 @@
|
|||||||
docker/Dockerfile.centos
|
docker/Dockerfile.alpine
|
@ -1,12 +1,13 @@
|
|||||||
FROM alpine:3.11 as build
|
FROM alpine:3.11 as build
|
||||||
|
|
||||||
RUN apk add --no-cache gcc g++ musl-dev linux-headers cmake openssl-dev
|
RUN apk add --no-cache \
|
||||||
RUN apk add --no-cache make
|
gcc g++ musl-dev linux-headers \
|
||||||
RUN apk add --no-cache zlib-dev
|
cmake mbedtls-dev make zlib-dev
|
||||||
|
|
||||||
RUN addgroup -S app && adduser -S -G app app
|
RUN addgroup -S app && \
|
||||||
RUN chown -R app:app /opt
|
adduser -S -G app app && \
|
||||||
RUN chown -R app:app /usr/local
|
chown -R app:app /opt && \
|
||||||
|
chown -R app:app /usr/local
|
||||||
|
|
||||||
# There is a bug in CMake where we cannot build from the root top folder
|
# There is a bug in CMake where we cannot build from the root top folder
|
||||||
# So we build from /opt
|
# So we build from /opt
|
||||||
@ -14,22 +15,21 @@ COPY --chown=app:app . /opt
|
|||||||
WORKDIR /opt
|
WORKDIR /opt
|
||||||
|
|
||||||
USER app
|
USER app
|
||||||
RUN [ "make", "ws_install" ]
|
RUN make ws_mbedtls_install && \
|
||||||
RUN [ "rm", "-rf", "build" ]
|
sh tools/trim_repo_for_docker.sh
|
||||||
|
|
||||||
FROM alpine:3.11 as runtime
|
FROM alpine:3.11 as runtime
|
||||||
|
|
||||||
RUN apk add --no-cache libstdc++
|
RUN apk add --no-cache libstdc++ mbedtls ca-certificates && \
|
||||||
RUN apk add --no-cache strace
|
addgroup -S app && \
|
||||||
RUN apk add --no-cache gdb
|
adduser -S -G app app
|
||||||
|
|
||||||
RUN addgroup -S app && adduser -S -G app app
|
|
||||||
COPY --chown=app:app --from=build /usr/local/bin/ws /usr/local/bin/ws
|
COPY --chown=app:app --from=build /usr/local/bin/ws /usr/local/bin/ws
|
||||||
RUN chmod +x /usr/local/bin/ws
|
|
||||||
RUN ldd /usr/local/bin/ws
|
|
||||||
|
|
||||||
# Copy source code for gcc
|
# COPY --chown=app:app --from=build /opt /opt
|
||||||
COPY --chown=app:app --from=build /opt /opt
|
|
||||||
|
RUN chmod +x /usr/local/bin/ws && \
|
||||||
|
ldd /usr/local/bin/ws
|
||||||
|
|
||||||
# Now run in usermode
|
# Now run in usermode
|
||||||
USER app
|
USER app
|
||||||
|
@ -1,6 +1,34 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [9.1.9] - 2020-03-30
|
||||||
|
|
||||||
|
(cobra to statsd bot) add ability to extract a numerical value and send a timer event to statsd, with the --timer option
|
||||||
|
|
||||||
|
## [9.1.8] - 2020-03-29
|
||||||
|
|
||||||
|
(cobra to statsd bot) bot init was missing + capture socket error
|
||||||
|
|
||||||
|
## [9.1.7] - 2020-03-29
|
||||||
|
|
||||||
|
(cobra to statsd bot) add ability to extract a numerical value and send a gauge event to statsd, with the --gauge option
|
||||||
|
|
||||||
|
## [9.1.6] - 2020-03-29
|
||||||
|
|
||||||
|
(ws cobra subscriber) use a Json::StreamWriter to write to std::cout, and save one std::string allocation for each message printed
|
||||||
|
|
||||||
|
## [9.1.5] - 2020-03-29
|
||||||
|
|
||||||
|
(docker) trim down docker image (300M -> 12M) / binary built without symbol and size optimization, and source code not copied over
|
||||||
|
|
||||||
|
## [9.1.4] - 2020-03-28
|
||||||
|
|
||||||
|
(jsoncpp) update bundled copy to version 1.9.3 (at sha 3beb37ea14aec1bdce1a6d542dc464d00f4a6cec)
|
||||||
|
|
||||||
|
## [9.1.3] - 2020-03-27
|
||||||
|
|
||||||
|
(docker) alpine docker build with release with debug info, and bundle ca-certificates
|
||||||
|
|
||||||
## [9.1.2] - 2020-03-26
|
## [9.1.2] - 2020-03-26
|
||||||
|
|
||||||
(mac ssl) rename DarwinSSL -> SecureTransport (see this too -> https://github.com/curl/curl/issues/3733)
|
(mac ssl) rename DarwinSSL -> SecureTransport (see this too -> https://github.com/curl/curl/issues/3733)
|
||||||
|
@ -40,7 +40,7 @@ namespace ix
|
|||||||
// Extract an attribute from a Json Value.
|
// Extract an attribute from a Json Value.
|
||||||
// extractAttr("foo.bar", {"foo": {"bar": "baz"}}) => baz
|
// extractAttr("foo.bar", {"foo": {"bar": "baz"}}) => baz
|
||||||
//
|
//
|
||||||
std::string extractAttr(const std::string& attr, const Json::Value& jsonValue)
|
Json::Value extractAttr(const std::string& attr, const Json::Value& jsonValue)
|
||||||
{
|
{
|
||||||
// Split by .
|
// Split by .
|
||||||
std::string token;
|
std::string token;
|
||||||
@ -53,7 +53,7 @@ namespace ix
|
|||||||
val = val[token];
|
val = val[token];
|
||||||
}
|
}
|
||||||
|
|
||||||
return val.asString();
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cobra_to_statsd_bot(const ix::CobraConfig& config,
|
int cobra_to_statsd_bot(const ix::CobraConfig& config,
|
||||||
@ -62,6 +62,8 @@ namespace ix
|
|||||||
const std::string& position,
|
const std::string& position,
|
||||||
StatsdClient& statsdClient,
|
StatsdClient& statsdClient,
|
||||||
const std::string& fields,
|
const std::string& fields,
|
||||||
|
const std::string& gauge,
|
||||||
|
const std::string& timer,
|
||||||
bool verbose,
|
bool verbose,
|
||||||
size_t maxQueueSize,
|
size_t maxQueueSize,
|
||||||
bool enableHeartbeat,
|
bool enableHeartbeat,
|
||||||
@ -81,7 +83,7 @@ namespace ix
|
|||||||
|
|
||||||
QueueManager queueManager(maxQueueSize);
|
QueueManager queueManager(maxQueueSize);
|
||||||
|
|
||||||
auto timer = [&sentCount, &receivedCount, &stop] {
|
auto progress = [&sentCount, &receivedCount, &stop] {
|
||||||
while (!stop)
|
while (!stop)
|
||||||
{
|
{
|
||||||
spdlog::info("messages received {} sent {}", receivedCount, sentCount);
|
spdlog::info("messages received {} sent {}", receivedCount, sentCount);
|
||||||
@ -93,7 +95,7 @@ namespace ix
|
|||||||
spdlog::info("timer thread done");
|
spdlog::info("timer thread done");
|
||||||
};
|
};
|
||||||
|
|
||||||
std::thread t1(timer);
|
std::thread t1(progress);
|
||||||
|
|
||||||
auto heartbeat = [&sentCount, &receivedCount, &stop, &enableHeartbeat] {
|
auto heartbeat = [&sentCount, &receivedCount, &stop, &enableHeartbeat] {
|
||||||
std::string state("na");
|
std::string state("na");
|
||||||
@ -124,7 +126,7 @@ namespace ix
|
|||||||
|
|
||||||
std::thread t2(heartbeat);
|
std::thread t2(heartbeat);
|
||||||
|
|
||||||
auto statsdSender = [&statsdClient, &queueManager, &sentCount, &tokens, &stop] {
|
auto statsdSender = [&statsdClient, &queueManager, &sentCount, &tokens, &stop, &gauge, &timer, &fatalCobraError, &verbose] {
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Json::Value msg = queueManager.pop();
|
Json::Value msg = queueManager.pop();
|
||||||
@ -136,10 +138,62 @@ namespace ix
|
|||||||
for (auto&& attr : tokens)
|
for (auto&& attr : tokens)
|
||||||
{
|
{
|
||||||
id += ".";
|
id += ".";
|
||||||
id += extractAttr(attr, msg);
|
auto val = extractAttr(attr, msg);
|
||||||
|
id += val.asString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gauge.empty() && timer.empty())
|
||||||
|
{
|
||||||
|
statsdClient.count(id, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string attrName = (!gauge.empty()) ? gauge : timer;
|
||||||
|
auto val = extractAttr(attrName, msg);
|
||||||
|
size_t x;
|
||||||
|
|
||||||
|
if (val.isInt())
|
||||||
|
{
|
||||||
|
x = (size_t) val.asInt();
|
||||||
|
}
|
||||||
|
else if (val.isInt64())
|
||||||
|
{
|
||||||
|
x = (size_t) val.asInt64();
|
||||||
|
}
|
||||||
|
else if (val.isUInt())
|
||||||
|
{
|
||||||
|
x = (size_t) val.asUInt();
|
||||||
|
}
|
||||||
|
else if (val.isUInt64())
|
||||||
|
{
|
||||||
|
x = (size_t) val.asUInt64();
|
||||||
|
}
|
||||||
|
else if (val.isDouble())
|
||||||
|
{
|
||||||
|
x = (size_t) val.asUInt64();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spdlog::error("Gauge {} is not a numberic type", gauge);
|
||||||
|
fatalCobraError = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
spdlog::info("{} - {} -> {}", id, attrName, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gauge.empty())
|
||||||
|
{
|
||||||
|
statsdClient.gauge(id, x);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
statsdClient.timing(id, x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
statsdClient.count(id, 1);
|
|
||||||
sentCount += 1;
|
sentCount += 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -18,6 +18,8 @@ namespace ix
|
|||||||
const std::string& position,
|
const std::string& position,
|
||||||
StatsdClient& statsdClient,
|
StatsdClient& statsdClient,
|
||||||
const std::string& fields,
|
const std::string& fields,
|
||||||
|
const std::string& gauge,
|
||||||
|
const std::string& timer,
|
||||||
bool verbose,
|
bool verbose,
|
||||||
size_t maxQueueSize,
|
size_t maxQueueSize,
|
||||||
bool enableHeartbeat,
|
bool enableHeartbeat,
|
||||||
|
@ -43,11 +43,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
{
|
{
|
||||||
const uint64_t StatsdClient::_maxQueueSize = 32768;
|
|
||||||
|
|
||||||
StatsdClient::StatsdClient(const std::string& host,
|
StatsdClient::StatsdClient(const std::string& host,
|
||||||
int port,
|
int port,
|
||||||
const std::string& prefix)
|
const std::string& prefix)
|
||||||
@ -56,23 +55,11 @@ namespace ix
|
|||||||
, _prefix(prefix)
|
, _prefix(prefix)
|
||||||
, _stop(false)
|
, _stop(false)
|
||||||
{
|
{
|
||||||
_thread = std::thread([this] {
|
_thread = std::thread([this]
|
||||||
|
{
|
||||||
while (!_stop)
|
while (!_stop)
|
||||||
{
|
{
|
||||||
std::deque<std::string> stagedQueue;
|
flushQueue();
|
||||||
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
|
||||||
_queue.swap(stagedQueue);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!stagedQueue.empty())
|
|
||||||
{
|
|
||||||
auto message = stagedQueue.front();
|
|
||||||
_socket.sendto(message);
|
|
||||||
stagedQueue.pop_front();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -127,31 +114,39 @@ namespace ix
|
|||||||
return send(key, ms, "ms");
|
return send(key, ms, "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
int StatsdClient::send(std::string key, size_t value, const std::string &type)
|
int StatsdClient::send(std::string key, size_t value, const std::string& type)
|
||||||
{
|
{
|
||||||
cleanup(key);
|
cleanup(key);
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
snprintf(buf, sizeof(buf), "%s%s:%zd|%s",
|
snprintf(buf, sizeof(buf), "%s%s:%zd|%s\n",
|
||||||
_prefix.c_str(), key.c_str(), value, type.c_str());
|
_prefix.c_str(), key.c_str(), value, type.c_str());
|
||||||
|
|
||||||
return send(buf);
|
enqueue(buf);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StatsdClient::send(const std::string &message)
|
void StatsdClient::enqueue(const std::string& message)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
|
_queue.push_back(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsdClient::flushQueue()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
|
|
||||||
if (_queue.empty() ||
|
while (!_queue.empty())
|
||||||
_queue.back().length() > _maxQueueSize)
|
|
||||||
{
|
{
|
||||||
_queue.push_back(message);
|
auto message = _queue.front();
|
||||||
|
auto ret = _socket.sendto(message);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
std::cerr << "error: "
|
||||||
|
<< strerror(UdpSocket::getErrno())
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
_queue.pop_front();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
(*_queue.rbegin()).append("\n").append(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
} // end namespace ix
|
} // end namespace ix
|
||||||
|
@ -32,11 +32,7 @@ namespace ix
|
|||||||
int timing(const std::string& key, size_t ms);
|
int timing(const std::string& key, size_t ms);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
void enqueue(const std::string& message);
|
||||||
* (Low Level Api) manually send a message
|
|
||||||
* which might be composed of several lines.
|
|
||||||
*/
|
|
||||||
int send(const std::string& message);
|
|
||||||
|
|
||||||
/* (Low Level Api) manually send a message
|
/* (Low Level Api) manually send a message
|
||||||
* type = "c", "g" or "ms"
|
* type = "c", "g" or "ms"
|
||||||
@ -44,6 +40,7 @@ namespace ix
|
|||||||
int send(std::string key, size_t value, const std::string& type);
|
int send(std::string key, size_t value, const std::string& type);
|
||||||
|
|
||||||
void cleanup(std::string& key);
|
void cleanup(std::string& key);
|
||||||
|
void flushQueue();
|
||||||
|
|
||||||
UdpSocket _socket;
|
UdpSocket _socket;
|
||||||
|
|
||||||
@ -56,7 +53,6 @@ namespace ix
|
|||||||
std::mutex _mutex; // for the queue
|
std::mutex _mutex; // for the queue
|
||||||
|
|
||||||
std::deque<std::string> _queue;
|
std::deque<std::string> _queue;
|
||||||
static const uint64_t _maxQueueSize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace ix
|
} // end namespace ix
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "9.1.2"
|
#define IX_WEBSOCKET_VERSION "9.1.9"
|
||||||
|
26
makefile
26
makefile
@ -1,5 +1,13 @@
|
|||||||
#
|
#
|
||||||
# This makefile is just used to easily work with docker (linux build)
|
# This makefile is used for convenience, and wrap simple cmake commands
|
||||||
|
# You don't need to use it as an end user, it is more for developer.
|
||||||
|
#
|
||||||
|
# * work with docker (linux build)
|
||||||
|
# * execute the unittest
|
||||||
|
#
|
||||||
|
# The default target will install ws, the command line tool coming with
|
||||||
|
# IXWebSocket into /usr/local/bin
|
||||||
|
#
|
||||||
#
|
#
|
||||||
all: brew
|
all: brew
|
||||||
|
|
||||||
@ -8,14 +16,23 @@ install: brew
|
|||||||
# Use -DCMAKE_INSTALL_PREFIX= to install into another location
|
# Use -DCMAKE_INSTALL_PREFIX= to install into another location
|
||||||
# on osx it is good practice to make /usr/local user writable
|
# on osx it is good practice to make /usr/local user writable
|
||||||
# sudo chown -R `whoami`/staff /usr/local
|
# sudo chown -R `whoami`/staff /usr/local
|
||||||
|
#
|
||||||
|
# Release, Debug, MinSizeRel, RelWithDebInfo are the build types
|
||||||
|
#
|
||||||
brew:
|
brew:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j 4 install)
|
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j 4 install)
|
||||||
|
|
||||||
|
# Docker default target. We've add problem with OpenSSL and TLS 1.3 (on the
|
||||||
|
# server side ?) and I can't work-around it easily, so we're using mbedtls on
|
||||||
|
# Linux for the SSL backend, which works great.
|
||||||
|
ws_mbedtls_install:
|
||||||
|
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j 4 install)
|
||||||
|
|
||||||
ws:
|
ws:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 .. ; make -j 4)
|
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 .. ; make -j 4)
|
||||||
|
|
||||||
ws_install:
|
ws_install:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 .. ; make -j 4 install)
|
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DUSE_TLS=1 -DUSE_WS=1 .. ; make -j 4 install)
|
||||||
|
|
||||||
ws_openssl:
|
ws_openssl:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_OPEN_SSL=1 .. ; make -j 4)
|
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_OPEN_SSL=1 .. ; make -j 4)
|
||||||
@ -23,9 +40,6 @@ ws_openssl:
|
|||||||
ws_mbedtls:
|
ws_mbedtls:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j 4)
|
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j 4)
|
||||||
|
|
||||||
ws_mbedtls_install:
|
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j 4 install)
|
|
||||||
|
|
||||||
ws_no_ssl:
|
ws_no_ssl:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_WS=1 .. ; make -j 4)
|
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_WS=1 .. ; make -j 4)
|
||||||
|
|
||||||
@ -68,6 +82,8 @@ docker_push:
|
|||||||
docker push ${LATEST}
|
docker push ${LATEST}
|
||||||
docker push ${IMG}
|
docker push ${IMG}
|
||||||
|
|
||||||
|
deploy: docker docker_push
|
||||||
|
|
||||||
run:
|
run:
|
||||||
docker run --cap-add sys_ptrace --entrypoint=sh -it bsergean/ws:build
|
docker run --cap-add sys_ptrace --entrypoint=sh -it bsergean/ws:build
|
||||||
|
|
||||||
|
@ -111,6 +111,8 @@ TEST_CASE("Cobra_to_statsd_bot", "[cobra_bots]")
|
|||||||
REQUIRE(initialized);
|
REQUIRE(initialized);
|
||||||
|
|
||||||
std::string fields("device.game\ndevice.os_name");
|
std::string fields("device.game\ndevice.os_name");
|
||||||
|
std::string gauge;
|
||||||
|
std::string timer;
|
||||||
|
|
||||||
int sentCount = ix::cobra_to_statsd_bot(config,
|
int sentCount = ix::cobra_to_statsd_bot(config,
|
||||||
channel,
|
channel,
|
||||||
@ -118,6 +120,8 @@ TEST_CASE("Cobra_to_statsd_bot", "[cobra_bots]")
|
|||||||
position,
|
position,
|
||||||
statsdClient,
|
statsdClient,
|
||||||
fields,
|
fields,
|
||||||
|
gauge,
|
||||||
|
timer,
|
||||||
verbose,
|
verbose,
|
||||||
maxQueueSize,
|
maxQueueSize,
|
||||||
enableHeartbeat,
|
enableHeartbeat,
|
||||||
|
207
third_party/jsoncpp/json/json-forwards.h
vendored
207
third_party/jsoncpp/json/json-forwards.h
vendored
@ -1,4 +1,4 @@
|
|||||||
/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).
|
/// Json-cpp amalgamated forward header (http://jsoncpp.sourceforge.net/).
|
||||||
/// It is intended to be used with #include "json/json-forwards.h"
|
/// It is intended to be used with #include "json/json-forwards.h"
|
||||||
/// This header provides forward declaration for all JsonCpp types.
|
/// This header provides forward declaration for all JsonCpp types.
|
||||||
|
|
||||||
@ -11,13 +11,13 @@ The JsonCpp library's source code, including accompanying documentation,
|
|||||||
tests and demonstration applications, are licensed under the following
|
tests and demonstration applications, are licensed under the following
|
||||||
conditions...
|
conditions...
|
||||||
|
|
||||||
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
|
||||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||||
this software is released into the Public Domain.
|
this software is released into the Public Domain.
|
||||||
|
|
||||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
||||||
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
|
||||||
released under the terms of the MIT License (see below).
|
The JsonCpp Authors, and is released under the terms of the MIT License (see below).
|
||||||
|
|
||||||
In jurisdictions which recognize Public Domain property, the user of this
|
In jurisdictions which recognize Public Domain property, the user of this
|
||||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||||
@ -32,7 +32,7 @@ described in clear, concise terms at:
|
|||||||
The full text of the MIT License follows:
|
The full text of the MIT License follows:
|
||||||
|
|
||||||
========================================================================
|
========================================================================
|
||||||
Copyright (c) 2007-2010 Baptiste Lepilleur
|
Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
@ -73,9 +73,9 @@ license you like.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
|
#ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED
|
||||||
# define JSON_FORWARD_AMALGATED_H_INCLUDED
|
# define JSON_FORWARD_AMALGAMATED_H_INCLUDED
|
||||||
/// If defined, indicates that the source file is amalgated
|
/// If defined, indicates that the source file is amalgamated
|
||||||
/// to prevent private header inclusion.
|
/// to prevent private header inclusion.
|
||||||
#define JSON_IS_AMALGAMATION
|
#define JSON_IS_AMALGAMATION
|
||||||
|
|
||||||
@ -83,23 +83,21 @@ license you like.
|
|||||||
// Beginning of content of file: include/json/config.h
|
// Beginning of content of file: include/json/config.h
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2010 Baptiste Lepilleur
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
|
|
||||||
#ifndef JSON_CONFIG_H_INCLUDED
|
#ifndef JSON_CONFIG_H_INCLUDED
|
||||||
#define JSON_CONFIG_H_INCLUDED
|
#define JSON_CONFIG_H_INCLUDED
|
||||||
|
#include <cstddef>
|
||||||
/// If defined, indicates that json library is embedded in CppTL library.
|
#include <cstdint>
|
||||||
//# define JSON_IN_CPPTL 1
|
#include <istream>
|
||||||
|
#include <memory>
|
||||||
/// If defined, indicates that json may leverage CppTL library
|
#include <ostream>
|
||||||
//# define JSON_USE_CPPTL 1
|
#include <sstream>
|
||||||
/// If defined, indicates that cpptl vector based map should be used instead of
|
#include <string>
|
||||||
/// std::map
|
#include <type_traits>
|
||||||
/// as Value container.
|
|
||||||
//# define JSON_USE_CPPTL_SMALLMAP 1
|
|
||||||
|
|
||||||
// If non-zero, the library uses exceptions to report bad input instead of C
|
// If non-zero, the library uses exceptions to report bad input instead of C
|
||||||
// assertion macros. The default is to use exceptions.
|
// assertion macros. The default is to use exceptions.
|
||||||
@ -107,43 +105,49 @@ license you like.
|
|||||||
#define JSON_USE_EXCEPTION 1
|
#define JSON_USE_EXCEPTION 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// If defined, indicates that the source file is amalgated
|
// Temporary, tracked for removal with issue #982.
|
||||||
|
#ifndef JSON_USE_NULLREF
|
||||||
|
#define JSON_USE_NULLREF 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// If defined, indicates that the source file is amalgamated
|
||||||
/// to prevent private header inclusion.
|
/// to prevent private header inclusion.
|
||||||
/// Remarks: it is automatically defined in the generated amalgated header.
|
/// Remarks: it is automatically defined in the generated amalgamated header.
|
||||||
// #define JSON_IS_AMALGAMATION
|
// #define JSON_IS_AMALGAMATION
|
||||||
|
|
||||||
#ifdef JSON_IN_CPPTL
|
// Export macros for DLL visibility
|
||||||
#include <cpptl/config.h>
|
#if defined(JSON_DLL_BUILD)
|
||||||
#ifndef JSON_USE_CPPTL
|
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||||
#define JSON_USE_CPPTL 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef JSON_IN_CPPTL
|
|
||||||
#define JSON_API CPPTL_API
|
|
||||||
#elif defined(JSON_DLL_BUILD)
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#define JSON_API __declspec(dllexport)
|
#define JSON_API __declspec(dllexport)
|
||||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||||
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
|
#define JSON_API __attribute__((visibility("default")))
|
||||||
#endif // if defined(_MSC_VER)
|
#endif // if defined(_MSC_VER)
|
||||||
|
|
||||||
#elif defined(JSON_DLL)
|
#elif defined(JSON_DLL)
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||||
#define JSON_API __declspec(dllimport)
|
#define JSON_API __declspec(dllimport)
|
||||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||||
#endif // if defined(_MSC_VER)
|
#endif // if defined(_MSC_VER)
|
||||||
#endif // ifdef JSON_IN_CPPTL
|
#endif // ifdef JSON_DLL_BUILD
|
||||||
|
|
||||||
#if !defined(JSON_API)
|
#if !defined(JSON_API)
|
||||||
#define JSON_API
|
#define JSON_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(JSON_HAS_UNIQUE_PTR)
|
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||||
#if __cplusplus >= 201103L
|
#error \
|
||||||
#define JSON_HAS_UNIQUE_PTR (1)
|
"ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
|
||||||
#elif _MSC_VER >= 1600
|
|
||||||
#define JSON_HAS_UNIQUE_PTR (1)
|
|
||||||
#else
|
|
||||||
#define JSON_HAS_UNIQUE_PTR (0)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
|
// As recommended at
|
||||||
|
// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
|
||||||
|
extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
|
||||||
|
const char* format, ...);
|
||||||
|
#define jsoncpp_snprintf msvc_pre1900_c99_snprintf
|
||||||
|
#else
|
||||||
|
#define jsoncpp_snprintf std::snprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
|
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
|
||||||
@ -151,55 +155,96 @@ license you like.
|
|||||||
// Storages, and 64 bits integer support is disabled.
|
// Storages, and 64 bits integer support is disabled.
|
||||||
// #define JSON_NO_INT64 1
|
// #define JSON_NO_INT64 1
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
|
// JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
|
||||||
// Microsoft Visual Studio 6 only support conversion from __int64 to double
|
// C++11 should be used directly in JSONCPP.
|
||||||
// (no conversion from unsigned __int64).
|
#define JSONCPP_OVERRIDE override
|
||||||
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
|
||||||
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
|
|
||||||
// characters in the debug information)
|
|
||||||
// All projects I've ever seen with VS6 were using this globally (not bothering
|
|
||||||
// with pragma push/pop).
|
|
||||||
#pragma warning(disable : 4786)
|
|
||||||
#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
|
#if __cplusplus >= 201103L
|
||||||
/// Indicates that the following function is deprecated.
|
#define JSONCPP_NOEXCEPT noexcept
|
||||||
|
#define JSONCPP_OP_EXPLICIT explicit
|
||||||
|
#elif defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
|
#define JSONCPP_NOEXCEPT throw()
|
||||||
|
#define JSONCPP_OP_EXPLICIT explicit
|
||||||
|
#elif defined(_MSC_VER) && _MSC_VER >= 1900
|
||||||
|
#define JSONCPP_NOEXCEPT noexcept
|
||||||
|
#define JSONCPP_OP_EXPLICIT explicit
|
||||||
|
#else
|
||||||
|
#define JSONCPP_NOEXCEPT throw()
|
||||||
|
#define JSONCPP_OP_EXPLICIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#if __has_extension(attribute_deprecated_with_message)
|
||||||
|
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__) // not clang (gcc comes later since clang emulates gcc)
|
||||||
|
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||||
|
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||||
|
#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||||
|
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
||||||
|
#endif // GNUC version
|
||||||
|
#elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates
|
||||||
|
// MSVC)
|
||||||
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
||||||
#elif defined(__clang__) && defined(__has_feature)
|
#endif // __clang__ || __GNUC__ || _MSC_VER
|
||||||
#if __has_feature(attribute_deprecated_with_message)
|
|
||||||
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
|
||||||
#endif
|
|
||||||
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
|
||||||
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
|
||||||
#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
|
||||||
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(JSONCPP_DEPRECATED)
|
#if !defined(JSONCPP_DEPRECATED)
|
||||||
#define JSONCPP_DEPRECATED(message)
|
#define JSONCPP_DEPRECATED(message)
|
||||||
#endif // if !defined(JSONCPP_DEPRECATED)
|
#endif // if !defined(JSONCPP_DEPRECATED)
|
||||||
|
|
||||||
|
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
|
||||||
|
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
typedef int Int;
|
using Int = int;
|
||||||
typedef unsigned int UInt;
|
using UInt = unsigned int;
|
||||||
#if defined(JSON_NO_INT64)
|
#if defined(JSON_NO_INT64)
|
||||||
typedef int LargestInt;
|
using LargestInt = int;
|
||||||
typedef unsigned int LargestUInt;
|
using LargestUInt = unsigned int;
|
||||||
#undef JSON_HAS_INT64
|
#undef JSON_HAS_INT64
|
||||||
#else // if defined(JSON_NO_INT64)
|
#else // if defined(JSON_NO_INT64)
|
||||||
// For Microsoft Visual use specific types as long long is not supported
|
// For Microsoft Visual use specific types as long long is not supported
|
||||||
#if defined(_MSC_VER) // Microsoft Visual Studio
|
#if defined(_MSC_VER) // Microsoft Visual Studio
|
||||||
typedef __int64 Int64;
|
using Int64 = __int64;
|
||||||
typedef unsigned __int64 UInt64;
|
using UInt64 = unsigned __int64;
|
||||||
#else // if defined(_MSC_VER) // Other platforms, use long long
|
#else // if defined(_MSC_VER) // Other platforms, use long long
|
||||||
typedef long long int Int64;
|
using Int64 = int64_t;
|
||||||
typedef unsigned long long int UInt64;
|
using UInt64 = uint64_t;
|
||||||
#endif // if defined(_MSC_VER)
|
#endif // if defined(_MSC_VER)
|
||||||
typedef Int64 LargestInt;
|
using LargestInt = Int64;
|
||||||
typedef UInt64 LargestUInt;
|
using LargestUInt = UInt64;
|
||||||
#define JSON_HAS_INT64
|
#define JSON_HAS_INT64
|
||||||
#endif // if defined(JSON_NO_INT64)
|
#endif // if defined(JSON_NO_INT64)
|
||||||
} // end namespace Json
|
|
||||||
|
template <typename T>
|
||||||
|
using Allocator =
|
||||||
|
typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
|
||||||
|
std::allocator<T>>::type;
|
||||||
|
using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
|
||||||
|
using IStringStream =
|
||||||
|
std::basic_istringstream<String::value_type, String::traits_type,
|
||||||
|
String::allocator_type>;
|
||||||
|
using OStringStream =
|
||||||
|
std::basic_ostringstream<String::value_type, String::traits_type,
|
||||||
|
String::allocator_type>;
|
||||||
|
using IStream = std::istream;
|
||||||
|
using OStream = std::ostream;
|
||||||
|
} // namespace Json
|
||||||
|
|
||||||
|
// Legacy names (formerly macros).
|
||||||
|
using JSONCPP_STRING = Json::String;
|
||||||
|
using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
|
||||||
|
using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
|
||||||
|
using JSONCPP_ISTREAM = Json::IStream;
|
||||||
|
using JSONCPP_OSTREAM = Json::OStream;
|
||||||
|
|
||||||
#endif // JSON_CONFIG_H_INCLUDED
|
#endif // JSON_CONFIG_H_INCLUDED
|
||||||
|
|
||||||
@ -216,7 +261,7 @@ typedef UInt64 LargestUInt;
|
|||||||
// Beginning of content of file: include/json/forwards.h
|
// Beginning of content of file: include/json/forwards.h
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2010 Baptiste Lepilleur
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@ -231,17 +276,23 @@ typedef UInt64 LargestUInt;
|
|||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
// writer.h
|
// writer.h
|
||||||
|
class StreamWriter;
|
||||||
|
class StreamWriterBuilder;
|
||||||
|
class Writer;
|
||||||
class FastWriter;
|
class FastWriter;
|
||||||
class StyledWriter;
|
class StyledWriter;
|
||||||
|
class StyledStreamWriter;
|
||||||
|
|
||||||
// reader.h
|
// reader.h
|
||||||
class Reader;
|
class Reader;
|
||||||
|
class CharReader;
|
||||||
|
class CharReaderBuilder;
|
||||||
|
|
||||||
// features.h
|
// json_features.h
|
||||||
class Features;
|
class Features;
|
||||||
|
|
||||||
// value.h
|
// value.h
|
||||||
typedef unsigned int ArrayIndex;
|
using ArrayIndex = unsigned int;
|
||||||
class StaticString;
|
class StaticString;
|
||||||
class Path;
|
class Path;
|
||||||
class PathArgument;
|
class PathArgument;
|
||||||
@ -262,4 +313,4 @@ class ValueConstIterator;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
|
#endif //ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED
|
||||||
|
1712
third_party/jsoncpp/json/json.h
vendored
1712
third_party/jsoncpp/json/json.h
vendored
File diff suppressed because it is too large
Load Diff
3168
third_party/jsoncpp/jsoncpp.cpp
vendored
3168
third_party/jsoncpp/jsoncpp.cpp
vendored
File diff suppressed because it is too large
Load Diff
6
tools/trim_repo_for_docker.sh
Normal file
6
tools/trim_repo_for_docker.sh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Used to clean up some non essential folders to make the ws container
|
||||||
|
|
||||||
|
rm -rf build
|
||||||
|
rm -rf third_party/zlib
|
||||||
|
rm -rf third_party/mbedtls
|
51
ws/ws.cpp
51
ws/ws.cpp
@ -70,6 +70,8 @@ int main(int argc, char** argv)
|
|||||||
std::string password;
|
std::string password;
|
||||||
std::string prefix("ws.test.v0");
|
std::string prefix("ws.test.v0");
|
||||||
std::string fields;
|
std::string fields;
|
||||||
|
std::string gauge;
|
||||||
|
std::string timer;
|
||||||
std::string dsn;
|
std::string dsn;
|
||||||
std::string redisHosts("127.0.0.1");
|
std::string redisHosts("127.0.0.1");
|
||||||
std::string redisPassword;
|
std::string redisPassword;
|
||||||
@ -264,6 +266,8 @@ int main(int argc, char** argv)
|
|||||||
cobra2statsd->add_option("--port", statsdPort, "Statsd port");
|
cobra2statsd->add_option("--port", statsdPort, "Statsd port");
|
||||||
cobra2statsd->add_option("--prefix", prefix, "Statsd prefix");
|
cobra2statsd->add_option("--prefix", prefix, "Statsd prefix");
|
||||||
cobra2statsd->add_option("--fields", fields, "Extract fields for naming the event")->join();
|
cobra2statsd->add_option("--fields", fields, "Extract fields for naming the event")->join();
|
||||||
|
cobra2statsd->add_option("--gauge", gauge, "Value to extract, and use as a statsd gauge")->join();
|
||||||
|
cobra2statsd->add_option("--timer", timer, "Value to extract, and use as a statsd timer")->join();
|
||||||
cobra2statsd->add_option("channel", channel, "Channel")->required();
|
cobra2statsd->add_option("channel", channel, "Channel")->required();
|
||||||
cobra2statsd->add_flag("-v", verbose, "Verbose");
|
cobra2statsd->add_flag("-v", verbose, "Verbose");
|
||||||
cobra2statsd->add_option("--pidfile", pidfile, "Pid file");
|
cobra2statsd->add_option("--pidfile", pidfile, "Pid file");
|
||||||
@ -453,20 +457,41 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
else if (app.got_subcommand("cobra_to_statsd"))
|
else if (app.got_subcommand("cobra_to_statsd"))
|
||||||
{
|
{
|
||||||
bool enableHeartbeat = true;
|
if (!timer.empty() && !gauge.empty())
|
||||||
int runtime = -1;
|
{
|
||||||
ix::StatsdClient statsdClient(hostname, statsdPort, prefix);
|
spdlog::error("--gauge and --timer options are exclusive. " \
|
||||||
|
"you can only supply one");
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool enableHeartbeat = true;
|
||||||
|
int runtime = -1; // run indefinitely
|
||||||
|
ix::StatsdClient statsdClient(hostname, statsdPort, prefix);
|
||||||
|
|
||||||
ret = ix::cobra_to_statsd_bot(cobraConfig,
|
std::string errMsg;
|
||||||
channel,
|
bool initialized = statsdClient.init(errMsg);
|
||||||
filter,
|
if (!initialized)
|
||||||
position,
|
{
|
||||||
statsdClient,
|
spdlog::error(errMsg);
|
||||||
fields,
|
ret = 1;
|
||||||
verbose,
|
}
|
||||||
maxQueueSize,
|
else
|
||||||
enableHeartbeat,
|
{
|
||||||
runtime);
|
ret = ix::cobra_to_statsd_bot(cobraConfig,
|
||||||
|
channel,
|
||||||
|
filter,
|
||||||
|
position,
|
||||||
|
statsdClient,
|
||||||
|
fields,
|
||||||
|
gauge,
|
||||||
|
timer,
|
||||||
|
verbose,
|
||||||
|
maxQueueSize,
|
||||||
|
enableHeartbeat,
|
||||||
|
runtime);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (app.got_subcommand("cobra_to_sentry"))
|
else if (app.got_subcommand("cobra_to_sentry"))
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,19 @@
|
|||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
{
|
{
|
||||||
|
using StreamWriterPtr = std::unique_ptr<Json::StreamWriter>;
|
||||||
|
|
||||||
|
StreamWriterPtr makeStreamWriter()
|
||||||
|
{
|
||||||
|
Json::StreamWriterBuilder builder;
|
||||||
|
builder["commentStyle"] = "None";
|
||||||
|
builder["indentation"] = ""; // will make the JSON object compact
|
||||||
|
std::unique_ptr<Json::StreamWriter> jsonWriter(builder.newStreamWriter());
|
||||||
|
return jsonWriter;
|
||||||
|
}
|
||||||
|
|
||||||
void writeToStdout(bool fluentd,
|
void writeToStdout(bool fluentd,
|
||||||
Json::FastWriter& jsonWriter,
|
const StreamWriterPtr& jsonWriter,
|
||||||
const Json::Value& msg,
|
const Json::Value& msg,
|
||||||
const std::string& position)
|
const std::string& position)
|
||||||
{
|
{
|
||||||
@ -29,12 +40,15 @@ namespace ix
|
|||||||
msgWithPosition["position"] = position;
|
msgWithPosition["position"] = position;
|
||||||
enveloppe["message"] = msgWithPosition;
|
enveloppe["message"] = msgWithPosition;
|
||||||
|
|
||||||
std::cout << jsonWriter.write(enveloppe);
|
jsonWriter->write(enveloppe, &std::cout);
|
||||||
|
std::cout << std::endl; // add lf and flush
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
enveloppe = msg;
|
enveloppe = msg;
|
||||||
std::cout << position << " " << jsonWriter.write(enveloppe);
|
std::cout << position << " ";
|
||||||
|
jsonWriter->write(enveloppe, &std::cout);
|
||||||
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,13 +63,10 @@ namespace ix
|
|||||||
conn.configure(config);
|
conn.configure(config);
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
|
||||||
Json::FastWriter jsonWriter;
|
|
||||||
|
|
||||||
// Display incoming messages
|
|
||||||
std::atomic<int> msgPerSeconds(0);
|
std::atomic<int> msgPerSeconds(0);
|
||||||
std::atomic<int> msgCount(0);
|
std::atomic<int> msgCount(0);
|
||||||
|
|
||||||
std::atomic<bool> fatalCobraError(false);
|
std::atomic<bool> fatalCobraError(false);
|
||||||
|
auto jsonWriter = makeStreamWriter();
|
||||||
|
|
||||||
auto timer = [&msgPerSeconds, &msgCount, &fatalCobraError] {
|
auto timer = [&msgPerSeconds, &msgCount, &fatalCobraError] {
|
||||||
while (!fatalCobraError)
|
while (!fatalCobraError)
|
||||||
|
Reference in New Issue
Block a user