diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/messagebus/message_status.h | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/messagebus/message_status.h')
-rw-r--r-- | library/cpp/messagebus/message_status.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/library/cpp/messagebus/message_status.h b/library/cpp/messagebus/message_status.h new file mode 100644 index 0000000000..e1878960b3 --- /dev/null +++ b/library/cpp/messagebus/message_status.h @@ -0,0 +1,57 @@ +#pragma once + +#include "codegen.h" +#include "defs.h" + +#include <library/cpp/deprecated/enum_codegen/enum_codegen.h> + +namespace NBus { +//////////////////////////////////////////////////////////////// +/// \brief Status of message communication + +#define MESSAGE_STATUS_MAP(XX) \ + XX(MESSAGE_OK, "OK") \ + XX(MESSAGE_CONNECT_FAILED, "Connect failed") \ + XX(MESSAGE_TIMEOUT, "Message timed out") \ + XX(MESSAGE_SERVICE_UNKNOWN, "Locator hasn't found address for key") \ + XX(MESSAGE_BUSY, "Too many messages in flight") \ + XX(MESSAGE_UNKNOWN, "Request not found by id, usually it means that message is timed out") \ + XX(MESSAGE_DESERIALIZE_ERROR, "Deserialize by TBusProtocol failed") \ + XX(MESSAGE_HEADER_CORRUPTED, "Header corrupted") \ + XX(MESSAGE_DECOMPRESS_ERROR, "Failed to decompress") \ + XX(MESSAGE_MESSAGE_TOO_LARGE, "Message too large") \ + XX(MESSAGE_REPLY_FAILED, "Unused by messagebus, used by other code") \ + XX(MESSAGE_DELIVERY_FAILED, "Message delivery failed because connection is closed") \ + XX(MESSAGE_INVALID_VERSION, "Protocol error: invalid version") \ + XX(MESSAGE_SERVICE_TOOMANY, "Locator failed to resolve address") \ + XX(MESSAGE_SHUTDOWN, "Failure because of either session or connection shutdown") \ + XX(MESSAGE_DONT_ASK, "Internal error code used by modules") + + enum EMessageStatus { + MESSAGE_STATUS_MAP(ENUM_VALUE_GEN_NO_VALUE) + MESSAGE_STATUS_COUNT + }; + + ENUM_TO_STRING(EMessageStatus, MESSAGE_STATUS_MAP) + + const char* MessageStatusDescription(EMessageStatus); + + static inline const char* GetMessageStatus(EMessageStatus status) { + return ToCString(status); + } + + // For lwtrace + struct TMessageStatusField { + typedef int TStoreType; + typedef int TFuncParam; + + static void ToString(int value, TString* out) { + *out = GetMessageStatus((NBus::EMessageStatus)value); + } + + static int ToStoreType(int value) { + return value; + } + }; + +} // ns |