-
Notifications
You must be signed in to change notification settings - Fork 29
/
decoder_events.h
150 lines (127 loc) · 5.37 KB
/
decoder_events.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
145
146
147
148
149
150
#pragma once
#include "src/application_protocols/thrift/metadata.h"
#include "src/application_protocols/thrift/thrift.h"
namespace Envoy {
namespace Extensions {
namespace NetworkFilters {
namespace ThriftProxy {
enum class FilterStatus {
// Continue filter chain iteration.
Continue,
// Stop iterating over filters in the filter chain. Iteration must be explicitly restarted via
// continueDecoding().
StopIteration
};
class DecoderEventHandler {
public:
virtual ~DecoderEventHandler() = default;
/**
* Indicates the start of a Thrift transport frame was detected. Unframed transports generate
* simulated start messages.
* @param metadata MessageMetadataSharedPtr describing as much as is currently known about the
* message
*/
virtual FilterStatus transportBegin(MessageMetadataSharedPtr metadata) PURE;
/**
* Indicates the end of a Thrift transport frame was detected. Unframed transport generate
* simulated complete messages.
*/
virtual FilterStatus transportEnd() PURE;
/**
* Indicates raw bytes after metadata in a Thrift transport frame was detected.
* Filters should not modify data except for the router.
* @param data data to send as passthrough
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus passthroughData(Buffer::Instance& data) PURE;
/**
* Indicates that the start of a Thrift protocol message was detected.
* @param metadata MessageMetadataSharedPtr describing the message
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus messageBegin(MessageMetadataSharedPtr metadata) PURE;
/**
* Indicates that the end of a Thrift protocol message was detected.
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus messageEnd() PURE;
/**
* Indicates that the start of a Thrift protocol struct was detected.
* @param name the name of the struct, if available
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus structBegin(absl::string_view name) PURE;
/**
* Indicates that the end of a Thrift protocol struct was detected.
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus structEnd() PURE;
/**
* Indicates that the start of Thrift protocol struct field was detected.
* @param name the name of the field, if available
* @param field_type the type of the field
* @param field_id the field id
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus fieldBegin(absl::string_view name, FieldType& field_type,
int16_t& field_id) PURE;
/**
* Indicates that the end of a Thrift protocol struct field was detected.
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus fieldEnd() PURE;
/**
* A struct field, map key, map value, list element or set element was detected.
* @param value type value of the field
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus boolValue(bool& value) PURE;
virtual FilterStatus byteValue(uint8_t& value) PURE;
virtual FilterStatus int16Value(int16_t& value) PURE;
virtual FilterStatus int32Value(int32_t& value) PURE;
virtual FilterStatus int64Value(int64_t& value) PURE;
virtual FilterStatus doubleValue(double& value) PURE;
virtual FilterStatus stringValue(absl::string_view value) PURE;
/**
* Indicates the start of a Thrift protocol map was detected.
* @param key_type the map key type
* @param value_type the map value type
* @param size the number of key-value pairs
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus mapBegin(FieldType& key_type, FieldType& value_type, uint32_t& size) PURE;
/**
* Indicates that the end of a Thrift protocol map was detected.
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus mapEnd() PURE;
/**
* Indicates the start of a Thrift protocol list was detected.
* @param elem_type the list value type
* @param size the number of values in the list
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus listBegin(FieldType& elem_type, uint32_t& size) PURE;
/**
* Indicates that the end of a Thrift protocol list was detected.
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus listEnd() PURE;
/**
* Indicates the start of a Thrift protocol set was detected.
* @param elem_type the set value type
* @param size the number of values in the set
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus setBegin(FieldType& elem_type, uint32_t& size) PURE;
/**
* Indicates that the end of a Thrift protocol set was detected.
* @return FilterStatus to indicate if filter chain iteration should continue
*/
virtual FilterStatus setEnd() PURE;
};
using DecoderEventHandlerSharedPtr = std::shared_ptr<DecoderEventHandler>;
} // namespace ThriftProxy
} // namespace NetworkFilters
} // namespace Extensions
} // namespace Envoy