forked from aeraki-mesh/meta-protocol-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage.h
144 lines (118 loc) · 3.63 KB
/
message.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#pragma once
#include <memory>
#include <string>
#include "envoy/common/pure.h"
#include "source/common/buffer/buffer_impl.h"
#include "absl/container/node_hash_map.h"
#include "absl/types/optional.h"
namespace Envoy {
namespace Extensions {
namespace NetworkFilters {
namespace MetaProtocolProxy {
namespace Dubbo {
/**
* Stream reset reasons.
*/
enum class StreamResetReason : uint8_t {
// If a local codec level reset was sent on the stream.
LocalReset,
// If a local codec level refused stream reset was sent on the stream (allowing for retry).
LocalRefusedStreamReset,
// If a remote codec level reset was received on the stream.
RemoteReset,
// If a remote codec level refused stream reset was received on the stream (allowing for retry).
RemoteRefusedStreamReset,
// If the stream was locally reset by a connection pool due to an initial connection failure.
ConnectionFailure,
// If the stream was locally reset due to connection termination.
ConnectionTermination,
// The stream was reset because of a resource overflow.
Overflow
};
// Supported protocol type
enum class ProtocolType : uint8_t {
Dubbo = 1,
// ATTENTION: MAKE SURE THIS REMAINS EQUAL TO THE LAST PROTOCOL TYPE
LastProtocolType = Dubbo,
};
// Supported serialization type
enum class SerializationType : uint8_t {
Hessian2 = 2,
};
// Message Type
enum class MessageType : uint8_t {
Response = 0,
Request = 1,
Oneway = 2,
Exception = 3,
HeartbeatRequest = 4,
HeartbeatResponse = 5,
// ATTENTION: MAKE SURE THIS REMAINS EQUAL TO THE LAST MESSAGE TYPE
LastMessageType = HeartbeatResponse,
};
/**
* Dubbo protocol response status types.
* See org.apache.dubbo.remoting.exchange
*/
enum class ResponseStatus : uint8_t {
Ok = 20,
ClientTimeout = 30,
ServerTimeout = 31,
BadRequest = 40,
BadResponse = 50,
ServiceNotFound = 60,
ServiceError = 70,
ServerError = 80,
ClientError = 90,
ServerThreadpoolExhaustedError = 100,
};
enum class RpcResponseType : uint8_t {
ResponseWithException = 0,
ResponseWithValue = 1,
ResponseWithNullValue = 2,
ResponseWithExceptionWithAttachments = 3,
ResponseValueWithAttachments = 4,
ResponseNullValueWithAttachments = 5,
};
class Context {
public:
virtual ~Context() = default;
Buffer::Instance& originMessage() { return origin_message_; }
size_t messageSize() const { return headerSize() + bodySize(); }
virtual size_t headerSize() const PURE;
virtual size_t bodySize() const PURE;
virtual bool isHeartbeat() const PURE;
protected:
Buffer::OwnedImpl origin_message_;
};
using ContextSharedPtr = std::shared_ptr<Context>;
/**
* RpcInvocation represent an rpc call
* See
* https://github.com/apache/incubator-dubbo/blob/master/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java
*/
class RpcInvocation {
public:
virtual ~RpcInvocation() = default;
virtual const std::string& serviceName() const PURE;
virtual const std::string& methodName() const PURE;
virtual const absl::optional<std::string>& serviceVersion() const PURE;
virtual const absl::optional<std::string>& serviceGroup() const PURE;
};
using RpcInvocationSharedPtr = std::shared_ptr<RpcInvocation>;
/**
* RpcResult represent the result of an rpc call
* See
* https://github.com/apache/incubator-dubbo/blob/master/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcResult.java
*/
class RpcResult {
public:
virtual ~RpcResult() = default;
virtual bool hasException() const PURE;
};
using RpcResultSharedPtr = std::shared_ptr<RpcResult>;
} // namespace Dubbo
} // namespace MetaProtocolProxy
} // namespace NetworkFilters
} // namespace Extensions
} // namespace Envoy