/proc/self/cwd/source/extensions/common/dubbo/codec.h
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | #include "source/extensions/common/dubbo/message.h" |
4 | | #include "source/extensions/common/dubbo/metadata.h" |
5 | | #include "source/extensions/common/dubbo/serializer.h" |
6 | | |
7 | | namespace Envoy { |
8 | | namespace Extensions { |
9 | | namespace Common { |
10 | | namespace Dubbo { |
11 | | |
12 | | enum DecodeStatus { |
13 | | Success, |
14 | | Failure, |
15 | | Waiting, |
16 | | }; |
17 | | |
18 | | class DubboCodec; |
19 | | using DubboCodecPtr = std::unique_ptr<DubboCodec>; |
20 | | |
21 | | class DubboCodec { |
22 | | public: |
23 | | static DubboCodecPtr codecFromSerializeType(SerializeType type); |
24 | | |
25 | | DecodeStatus decodeHeader(Buffer::Instance& buffer, MessageMetadata& metadata); |
26 | | |
27 | | DecodeStatus decodeData(Buffer::Instance& buffer, MessageMetadata& metadata); |
28 | | |
29 | | void encode(Buffer::Instance& buffer, MessageMetadata& metadata); |
30 | | |
31 | 0 | void initilize(SerializerPtr serializer) { serializer_ = std::move(serializer); } |
32 | | |
33 | 0 | const SerializerPtr& serializer() const { return serializer_; } |
34 | | |
35 | | // Encode header only. In most cases, the 'encode' should be used and this method |
36 | | // just used for test. |
37 | | void encodeHeaderForTest(Buffer::Instance& buffer, Context& context); |
38 | | |
39 | | static constexpr uint8_t HeadersSize = 16; |
40 | | static constexpr int32_t MaxBodySize = 16 * 1024 * 1024; |
41 | | |
42 | | private: |
43 | | SerializerPtr serializer_{}; |
44 | | }; |
45 | | |
46 | | class DirectResponseUtil { |
47 | | public: |
48 | | static MessageMetadataSharedPtr heartbeatResponse(MessageMetadata& heartbeat_request); |
49 | | static MessageMetadataSharedPtr localResponse(MessageMetadata& request, ResponseStatus status, |
50 | | absl::optional<RpcResponseType> type, |
51 | | absl::string_view content); |
52 | | }; |
53 | | |
54 | | } // namespace Dubbo |
55 | | } // namespace Common |
56 | | } // namespace Extensions |
57 | | } // namespace Envoy |