(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:
		| @@ -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); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user