/proc/self/cwd/source/extensions/io_socket/user_space/io_handle.h
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | #include "envoy/buffer/buffer.h" |
4 | | #include "envoy/common/optref.h" |
5 | | #include "envoy/common/pure.h" |
6 | | #include "envoy/config/core/v3/base.pb.h" |
7 | | #include "envoy/stream_info/filter_state.h" |
8 | | |
9 | | namespace Envoy { |
10 | | namespace Extensions { |
11 | | namespace IoSocket { |
12 | | namespace UserSpace { |
13 | | |
14 | | // Shared state between peering user space IO handles. |
15 | | class PassthroughState { |
16 | | public: |
17 | 0 | virtual ~PassthroughState() = default; |
18 | | |
19 | | /** |
20 | | * Initialize the passthrough state from the downstream. This should be |
21 | | * called at most once before `mergeInto`. |
22 | | */ |
23 | | virtual void initialize(std::unique_ptr<envoy::config::core::v3::Metadata> metadata, |
24 | | const StreamInfo::FilterState::Objects& filter_state_objects) PURE; |
25 | | |
26 | | /** |
27 | | * Merge the passthrough state into a recipient stream metadata and its |
28 | | * filter state. This should be called at most once after `initialize`. |
29 | | */ |
30 | | virtual void mergeInto(envoy::config::core::v3::Metadata& metadata, |
31 | | StreamInfo::FilterState& filter_state) PURE; |
32 | | }; |
33 | | |
34 | | using PassthroughStateSharedPtr = std::shared_ptr<PassthroughState>; |
35 | | |
36 | | /** |
37 | | * The interface for the peer as a writer and supplied read status query. |
38 | | */ |
39 | | class IoHandle { |
40 | | public: |
41 | 0 | virtual ~IoHandle() = default; |
42 | | |
43 | | /** |
44 | | * Set the flag to indicate no further write from peer. |
45 | | */ |
46 | | virtual void setWriteEnd() PURE; |
47 | | |
48 | | /** |
49 | | * @return true if the peer promise no more write. |
50 | | */ |
51 | | virtual bool isPeerShutDownWrite() const PURE; |
52 | | |
53 | | /** |
54 | | * Raised when peer is destroyed. No further write to peer is allowed. |
55 | | */ |
56 | | virtual void onPeerDestroy() PURE; |
57 | | |
58 | | /** |
59 | | * Notify that consumable data arrived. The consumable data can be either data to read, or the end |
60 | | * of stream event. |
61 | | */ |
62 | | virtual void setNewDataAvailable() PURE; |
63 | | |
64 | | /** |
65 | | * @return the buffer to be written. |
66 | | */ |
67 | | virtual Buffer::Instance* getWriteBuffer() PURE; |
68 | | |
69 | | /** |
70 | | * @return true if more data is acceptable at the destination buffer. |
71 | | */ |
72 | | virtual bool isWritable() const PURE; |
73 | | |
74 | | /** |
75 | | * @return true if peer is valid and writable. |
76 | | */ |
77 | | virtual bool isPeerWritable() const PURE; |
78 | | |
79 | | /** |
80 | | * Raised by the peer when the peer switch from high water mark to low. |
81 | | */ |
82 | | virtual void onPeerBufferLowWatermark() PURE; |
83 | | |
84 | | /** |
85 | | * @return true if the pending receive buffer is not empty or read_end is set. |
86 | | */ |
87 | | virtual bool isReadable() const PURE; |
88 | | |
89 | | /** |
90 | | * @return shared state between peering user space IO handles. |
91 | | */ |
92 | | virtual PassthroughStateSharedPtr passthroughState() PURE; |
93 | | }; |
94 | | } // namespace UserSpace |
95 | | } // namespace IoSocket |
96 | | } // namespace Extensions |
97 | | } // namespace Envoy |