(redis cobra bots) xadd with maxlen + fix bug in xadd client implementation and ws cobra metrics to redis command argument parsing
This commit is contained in:
parent
c5aadffa08
commit
d0cd4aed5a
@ -1,6 +1,10 @@
|
|||||||
# 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.7.0] - 2020-06-11
|
||||||
|
|
||||||
|
(redis cobra bots) xadd with maxlen + fix bug in xadd client implementation and ws cobra metrics to redis command argument parsing
|
||||||
|
|
||||||
## [9.6.9] - 2020-06-10
|
## [9.6.9] - 2020-06-10
|
||||||
|
|
||||||
(redis cobra bots) update the cobra to redis bot to use the bot framework, and change it to report fps metrics into redis streams.
|
(redis cobra bots) update the cobra to redis bot to use the bot framework, and change it to report fps metrics into redis streams.
|
||||||
|
@ -45,21 +45,27 @@ namespace ix
|
|||||||
slowFrames += frameRateHistogramCounts[6].asInt();
|
slowFrames += frameRateHistogramCounts[6].asInt();
|
||||||
slowFrames += frameRateHistogramCounts[7].asInt();
|
slowFrames += frameRateHistogramCounts[7].asInt();
|
||||||
|
|
||||||
|
//
|
||||||
|
// XADD without a device id
|
||||||
|
//
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << msg["id"].asString() << "_slow_frames" << "."
|
ss << msg["id"].asString() << "_slow_frames" << "."
|
||||||
<< msg["device"]["game"].asString() << "."
|
<< msg["device"]["game"].asString() << "."
|
||||||
<< msg["device"]["os_name"].asString() << "."
|
<< msg["device"]["os_name"].asString() << "."
|
||||||
<< removeSpaces(msg["data"]["Tag"].asString());
|
<< removeSpaces(msg["data"]["Tag"].asString());
|
||||||
|
|
||||||
|
int maxLen;
|
||||||
|
maxLen = 100000;
|
||||||
std::string id = ss.str();
|
std::string id = ss.str();
|
||||||
std::string errMsg;
|
std::string errMsg;
|
||||||
if (redisClient.xadd(id, std::to_string(slowFrames), errMsg).empty())
|
if (redisClient.xadd(id, std::to_string(slowFrames), maxLen, errMsg).empty())
|
||||||
{
|
{
|
||||||
CoreLogger::info(std::string("redis xadd error: ") + errMsg);
|
CoreLogger::info(std::string("redis xadd error: ") + errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceId == "N841AP" || deviceId == "SM-N960U")
|
//
|
||||||
{
|
// XADD with a device id
|
||||||
|
//
|
||||||
ss.str(""); // reset the stringstream
|
ss.str(""); // reset the stringstream
|
||||||
ss << msg["id"].asString() << "_slow_frames_by_device" << "."
|
ss << msg["id"].asString() << "_slow_frames_by_device" << "."
|
||||||
<< deviceId << "."
|
<< deviceId << "."
|
||||||
@ -67,12 +73,12 @@ namespace ix
|
|||||||
<< msg["device"]["os_name"].asString() << "."
|
<< msg["device"]["os_name"].asString() << "."
|
||||||
<< removeSpaces(msg["data"]["Tag"].asString());
|
<< removeSpaces(msg["data"]["Tag"].asString());
|
||||||
|
|
||||||
std::string id = ss.str();
|
id = ss.str();
|
||||||
if (redisClient.xadd(id, std::to_string(slowFrames), errMsg).empty())
|
maxLen = 1000;
|
||||||
|
if (redisClient.xadd(id, std::to_string(slowFrames), maxLen, errMsg).empty())
|
||||||
{
|
{
|
||||||
CoreLogger::info(std::string("redis xadd error: ") + errMsg);
|
CoreLogger::info(std::string("redis xadd error: ") + errMsg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -251,12 +251,16 @@ namespace ix
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string RedisClient::prepareXaddCommand(const std::string& stream,
|
std::string RedisClient::prepareXaddCommand(const std::string& stream,
|
||||||
const std::string& message)
|
const std::string& message,
|
||||||
|
int maxLen)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "*5\r\n";
|
ss << "*8\r\n";
|
||||||
ss << writeString("XADD");
|
ss << writeString("XADD");
|
||||||
ss << writeString(stream);
|
ss << writeString(stream);
|
||||||
|
ss << writeString("MAXLEN");
|
||||||
|
ss << writeString("~");
|
||||||
|
ss << writeString(std::to_string(maxLen));
|
||||||
ss << writeString("*");
|
ss << writeString("*");
|
||||||
ss << writeString("field");
|
ss << writeString("field");
|
||||||
ss << writeString(message);
|
ss << writeString(message);
|
||||||
@ -266,6 +270,7 @@ namespace ix
|
|||||||
|
|
||||||
std::string RedisClient::xadd(const std::string& stream,
|
std::string RedisClient::xadd(const std::string& stream,
|
||||||
const std::string& message,
|
const std::string& message,
|
||||||
|
int maxLen,
|
||||||
std::string& errMsg)
|
std::string& errMsg)
|
||||||
{
|
{
|
||||||
errMsg.clear();
|
errMsg.clear();
|
||||||
@ -276,7 +281,7 @@ namespace ix
|
|||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string command = prepareXaddCommand(stream, message);
|
std::string command = prepareXaddCommand(stream, message, maxLen);
|
||||||
|
|
||||||
bool sent = _socket->writeBytes(command, nullptr);
|
bool sent = _socket->writeBytes(command, nullptr);
|
||||||
if (!sent)
|
if (!sent)
|
||||||
|
@ -40,9 +40,12 @@ namespace ix
|
|||||||
// XADD
|
// XADD
|
||||||
std::string xadd(const std::string& channel,
|
std::string xadd(const std::string& channel,
|
||||||
const std::string& message,
|
const std::string& message,
|
||||||
|
int maxLen,
|
||||||
std::string& errMsg);
|
std::string& errMsg);
|
||||||
|
|
||||||
std::string prepareXaddCommand(const std::string& stream, const std::string& message);
|
std::string prepareXaddCommand(const std::string& stream,
|
||||||
|
const std::string& message,
|
||||||
|
int maxLen);
|
||||||
|
|
||||||
std::string readXaddReply(std::string& errMsg);
|
std::string readXaddReply(std::string& errMsg);
|
||||||
|
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "9.6.9"
|
#define IX_WEBSOCKET_VERSION "9.7.0"
|
||||||
|
@ -370,7 +370,7 @@ int main(int argc, char** argv)
|
|||||||
cobra2redisApp->add_option("--port", redisPort, "Redis port");
|
cobra2redisApp->add_option("--port", redisPort, "Redis port");
|
||||||
cobra2redisApp->add_flag("-v", verbose, "Verbose");
|
cobra2redisApp->add_flag("-v", verbose, "Verbose");
|
||||||
addTLSOptions(cobra2redisApp);
|
addTLSOptions(cobra2redisApp);
|
||||||
addCobraConfig(cobra2redisApp);
|
addCobraBotConfig(cobra2redisApp);
|
||||||
|
|
||||||
CLI::App* snakeApp = app.add_subcommand("snake", "Snake server");
|
CLI::App* snakeApp = app.add_subcommand("snake", "Snake server");
|
||||||
snakeApp->fallthrough();
|
snakeApp->fallthrough();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user