Coverage Report

Created: 2023-11-12 09:30

/proc/self/cwd/source/extensions/filters/network/dubbo_proxy/message.h
Line
Count
Source (jump to first uncovered line)
1
#pragma once
2
3
#include <memory>
4
#include <string>
5
6
#include "envoy/common/pure.h"
7
8
#include "source/common/buffer/buffer_impl.h"
9
10
#include "absl/container/node_hash_map.h"
11
#include "absl/types/optional.h"
12
13
namespace Envoy {
14
namespace Extensions {
15
namespace NetworkFilters {
16
namespace DubboProxy {
17
18
/**
19
 * Stream reset reasons.
20
 */
21
enum class StreamResetReason : uint8_t {
22
  // If a local codec level reset was sent on the stream.
23
  LocalReset,
24
  // If a local codec level refused stream reset was sent on the stream (allowing for retry).
25
  LocalRefusedStreamReset,
26
  // If a remote codec level reset was received on the stream.
27
  RemoteReset,
28
  // If a remote codec level refused stream reset was received on the stream (allowing for retry).
29
  RemoteRefusedStreamReset,
30
  // If the stream was locally reset by a connection pool due to an initial connection failure.
31
  ConnectionFailure,
32
  // If the stream was locally reset due to connection termination.
33
  ConnectionTermination,
34
  // The stream was reset because of a resource overflow.
35
  Overflow
36
};
37
38
// Supported protocol type
39
enum class ProtocolType : uint8_t {
40
  Dubbo = 1,
41
42
  // ATTENTION: MAKE SURE THIS REMAINS EQUAL TO THE LAST PROTOCOL TYPE
43
  LastProtocolType = Dubbo,
44
};
45
46
// Supported serialization type
47
enum class SerializationType : uint8_t {
48
  Hessian2 = 2,
49
};
50
51
// Message Type
52
enum class MessageType : uint8_t {
53
  Response = 0,
54
  Request = 1,
55
  Oneway = 2,
56
  Exception = 3,
57
  HeartbeatRequest = 4,
58
  HeartbeatResponse = 5,
59
60
  // ATTENTION: MAKE SURE THIS REMAINS EQUAL TO THE LAST MESSAGE TYPE
61
  LastMessageType = HeartbeatResponse,
62
};
63
64
/**
65
 * Dubbo protocol response status types.
66
 * See org.apache.dubbo.remoting.exchange
67
 */
68
enum class ResponseStatus : uint8_t {
69
  Ok = 20,
70
  ClientTimeout = 30,
71
  ServerTimeout = 31,
72
  BadRequest = 40,
73
  BadResponse = 50,
74
  ServiceNotFound = 60,
75
  ServiceError = 70,
76
  ServerError = 80,
77
  ClientError = 90,
78
  ServerThreadpoolExhaustedError = 100,
79
};
80
81
enum class RpcResponseType : uint8_t {
82
  ResponseWithException = 0,
83
  ResponseWithValue = 1,
84
  ResponseWithNullValue = 2,
85
  ResponseWithExceptionWithAttachments = 3,
86
  ResponseValueWithAttachments = 4,
87
  ResponseNullValueWithAttachments = 5,
88
};
89
90
class Context {
91
public:
92
0
  virtual ~Context() = default;
93
94
0
  Buffer::Instance& originMessage() { return origin_message_; }
95
0
  size_t messageSize() const { return headerSize() + bodySize(); }
96
97
  virtual size_t headerSize() const PURE;
98
  virtual size_t bodySize() const PURE;
99
100
  virtual bool isHeartbeat() const PURE;
101
102
protected:
103
  Buffer::OwnedImpl origin_message_;
104
};
105
106
using ContextSharedPtr = std::shared_ptr<Context>;
107
108
/**
109
 * RpcInvocation represent an rpc call
110
 * See
111
 * https://github.com/apache/incubator-dubbo/blob/master/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java
112
 */
113
class RpcInvocation {
114
public:
115
0
  virtual ~RpcInvocation() = default;
116
117
  virtual const std::string& serviceName() const PURE;
118
  virtual const std::string& methodName() const PURE;
119
  virtual const absl::optional<std::string>& serviceVersion() const PURE;
120
  virtual const absl::optional<std::string>& serviceGroup() const PURE;
121
};
122
123
using RpcInvocationSharedPtr = std::shared_ptr<RpcInvocation>;
124
125
/**
126
 * RpcResult represent the result of an rpc call
127
 * See
128
 * https://github.com/apache/incubator-dubbo/blob/master/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcResult.java
129
 */
130
class RpcResult {
131
public:
132
0
  virtual ~RpcResult() = default;
133
134
  virtual bool hasException() const PURE;
135
};
136
137
using RpcResultSharedPtr = std::shared_ptr<RpcResult>;
138
139
} // namespace DubboProxy
140
} // namespace NetworkFilters
141
} // namespace Extensions
142
} // namespace Envoy