message_status.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include "codegen.h"
  3. #include "defs.h"
  4. #include <library/cpp/deprecated/enum_codegen/enum_codegen.h>
  5. namespace NBus {
  6. ////////////////////////////////////////////////////////////////
  7. /// \brief Status of message communication
  8. #define MESSAGE_STATUS_MAP(XX) \
  9. XX(MESSAGE_OK, "OK") \
  10. XX(MESSAGE_CONNECT_FAILED, "Connect failed") \
  11. XX(MESSAGE_TIMEOUT, "Message timed out") \
  12. XX(MESSAGE_SERVICE_UNKNOWN, "Locator hasn't found address for key") \
  13. XX(MESSAGE_BUSY, "Too many messages in flight") \
  14. XX(MESSAGE_UNKNOWN, "Request not found by id, usually it means that message is timed out") \
  15. XX(MESSAGE_DESERIALIZE_ERROR, "Deserialize by TBusProtocol failed") \
  16. XX(MESSAGE_HEADER_CORRUPTED, "Header corrupted") \
  17. XX(MESSAGE_DECOMPRESS_ERROR, "Failed to decompress") \
  18. XX(MESSAGE_MESSAGE_TOO_LARGE, "Message too large") \
  19. XX(MESSAGE_REPLY_FAILED, "Unused by messagebus, used by other code") \
  20. XX(MESSAGE_DELIVERY_FAILED, "Message delivery failed because connection is closed") \
  21. XX(MESSAGE_INVALID_VERSION, "Protocol error: invalid version") \
  22. XX(MESSAGE_SERVICE_TOOMANY, "Locator failed to resolve address") \
  23. XX(MESSAGE_SHUTDOWN, "Failure because of either session or connection shutdown") \
  24. XX(MESSAGE_DONT_ASK, "Internal error code used by modules")
  25. enum EMessageStatus {
  26. MESSAGE_STATUS_MAP(ENUM_VALUE_GEN_NO_VALUE)
  27. MESSAGE_STATUS_COUNT
  28. };
  29. ENUM_TO_STRING(EMessageStatus, MESSAGE_STATUS_MAP)
  30. const char* MessageStatusDescription(EMessageStatus);
  31. static inline const char* GetMessageStatus(EMessageStatus status) {
  32. return ToCString(status);
  33. }
  34. // For lwtrace
  35. struct TMessageStatusField {
  36. typedef int TStoreType;
  37. typedef int TFuncParam;
  38. static void ToString(int value, TString* out) {
  39. *out = GetMessageStatus((NBus::EMessageStatus)value);
  40. }
  41. static int ToStoreType(int value) {
  42. return value;
  43. }
  44. };
  45. } // ns