(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
|
||||
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
|
||||
|
||||
(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,33 +45,39 @@ namespace ix
|
||||
slowFrames += frameRateHistogramCounts[6].asInt();
|
||||
slowFrames += frameRateHistogramCounts[7].asInt();
|
||||
|
||||
//
|
||||
// XADD without a device id
|
||||
//
|
||||
std::stringstream ss;
|
||||
ss << msg["id"].asString() << "_slow_frames" << "."
|
||||
<< msg["device"]["game"].asString() << "."
|
||||
<< msg["device"]["os_name"].asString() << "."
|
||||
<< removeSpaces(msg["data"]["Tag"].asString());
|
||||
|
||||
int maxLen;
|
||||
maxLen = 100000;
|
||||
std::string id = ss.str();
|
||||
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);
|
||||
}
|
||||
|
||||
if (deviceId == "N841AP" || deviceId == "SM-N960U")
|
||||
{
|
||||
ss.str(""); // reset the stringstream
|
||||
ss << msg["id"].asString() << "_slow_frames_by_device" << "."
|
||||
<< deviceId << "."
|
||||
<< msg["device"]["game"].asString() << "."
|
||||
<< msg["device"]["os_name"].asString() << "."
|
||||
<< removeSpaces(msg["data"]["Tag"].asString());
|
||||
//
|
||||
// XADD with a device id
|
||||
//
|
||||
ss.str(""); // reset the stringstream
|
||||
ss << msg["id"].asString() << "_slow_frames_by_device" << "."
|
||||
<< deviceId << "."
|
||||
<< msg["device"]["game"].asString() << "."
|
||||
<< msg["device"]["os_name"].asString() << "."
|
||||
<< removeSpaces(msg["data"]["Tag"].asString());
|
||||
|
||||
std::string id = ss.str();
|
||||
if (redisClient.xadd(id, std::to_string(slowFrames), errMsg).empty())
|
||||
{
|
||||
CoreLogger::info(std::string("redis xadd error: ") + errMsg);
|
||||
}
|
||||
id = ss.str();
|
||||
maxLen = 1000;
|
||||
if (redisClient.xadd(id, std::to_string(slowFrames), maxLen, errMsg).empty())
|
||||
{
|
||||
CoreLogger::info(std::string("redis xadd error: ") + errMsg);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -251,12 +251,16 @@ namespace ix
|
||||
}
|
||||
|
||||
std::string RedisClient::prepareXaddCommand(const std::string& stream,
|
||||
const std::string& message)
|
||||
const std::string& message,
|
||||
int maxLen)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "*5\r\n";
|
||||
ss << "*8\r\n";
|
||||
ss << writeString("XADD");
|
||||
ss << writeString(stream);
|
||||
ss << writeString("MAXLEN");
|
||||
ss << writeString("~");
|
||||
ss << writeString(std::to_string(maxLen));
|
||||
ss << writeString("*");
|
||||
ss << writeString("field");
|
||||
ss << writeString(message);
|
||||
@ -266,6 +270,7 @@ namespace ix
|
||||
|
||||
std::string RedisClient::xadd(const std::string& stream,
|
||||
const std::string& message,
|
||||
int maxLen,
|
||||
std::string& errMsg)
|
||||
{
|
||||
errMsg.clear();
|
||||
@ -276,7 +281,7 @@ namespace ix
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string command = prepareXaddCommand(stream, message);
|
||||
std::string command = prepareXaddCommand(stream, message, maxLen);
|
||||
|
||||
bool sent = _socket->writeBytes(command, nullptr);
|
||||
if (!sent)
|
||||
|
@ -40,9 +40,12 @@ namespace ix
|
||||
// XADD
|
||||
std::string xadd(const std::string& channel,
|
||||
const std::string& message,
|
||||
int maxLen,
|
||||
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);
|
||||
|
||||
|
@ -6,4 +6,4 @@
|
||||
|
||||
#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_flag("-v", verbose, "Verbose");
|
||||
addTLSOptions(cobra2redisApp);
|
||||
addCobraConfig(cobra2redisApp);
|
||||
addCobraBotConfig(cobra2redisApp);
|
||||
|
||||
CLI::App* snakeApp = app.add_subcommand("snake", "Snake server");
|
||||
snakeApp->fallthrough();
|
||||
|
Loading…
Reference in New Issue
Block a user