aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/message_status.h
blob: 98273a5a5cab5ed17feae0a034498aab6a2f7987 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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