forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flow control: side stream flow control part 2 (envoyproxy#35077)
- Deprecated and replaced the `DecoderFilterWatermarkCallbacks` that was introduced [PR](envoyproxy#25207) with `SidestreamWatermarkCallbacks` in this PR so that both encoder and decode filter callbacks can be registered - Implements sidestream push back on upstream Risk Level: Low, existing runtime guard Testing: integration test and unit test Docs Changes: N/A. a design doc in draft https://docs.google.com/document/d/1fwISI5wKQe6H3EOuaDLrAAgPU8Hq3KXaxJG0pm3vu-4/edit#heading=h.xgjl2srtytjt and will add it to envoy flow control doc in the end or at least when full flow control is approved. Release Notes: N/A Platform Specific Features: N/A --------- Signed-off-by: tyxia <[email protected]> Signed-off-by: asingh-g <[email protected]>
- Loading branch information
Showing
30 changed files
with
291 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#pragma once | ||
|
||
#include "envoy/http/async_client.h" | ||
|
||
namespace Envoy { | ||
namespace Http { | ||
|
||
/** | ||
* Sidestream watermark callback implementation for stream filter that either handles decoding only | ||
* or handles both encoding and decoding. | ||
*/ | ||
class StreamFilterSidestreamWatermarkCallbacks : public Http::SidestreamWatermarkCallbacks { | ||
public: | ||
void onSidestreamAboveHighWatermark() final { | ||
// Sidestream push back downstream, if callback is configured. | ||
if (decode_callback_ != nullptr) { | ||
decode_callback_->onDecoderFilterAboveWriteBufferHighWatermark(); | ||
} | ||
|
||
// Sidestream push back upstream, if callback is configured. | ||
if (encode_callback_ != nullptr) { | ||
encode_callback_->onEncoderFilterAboveWriteBufferHighWatermark(); | ||
} | ||
} | ||
|
||
void onSidestreamBelowLowWatermark() final { | ||
if (decode_callback_ != nullptr) { | ||
decode_callback_->onDecoderFilterBelowWriteBufferLowWatermark(); | ||
} | ||
|
||
if (encode_callback_ != nullptr) { | ||
encode_callback_->onEncoderFilterBelowWriteBufferLowWatermark(); | ||
} | ||
} | ||
|
||
/** | ||
* The set function needs to be called by stream decoder filter before side stream connection is | ||
* established, to apply the backpressure to downstream when it is above watermark, | ||
*/ | ||
void setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks* decode_callback) { | ||
decode_callback_ = decode_callback; | ||
} | ||
|
||
/** | ||
* The set function needs to be called by stream encoder filter before side stream connection is | ||
* established, to apply the backpressure to upstream when it is above watermark, | ||
*/ | ||
void setEncoderFilterCallbacks(Http::StreamEncoderFilterCallbacks* encode_callback) { | ||
encode_callback_ = encode_callback; | ||
} | ||
|
||
private: | ||
// Non owning pointers; `removeWatermarkCallbacks()` needs to be called to unregister watermark | ||
// callbacks (if any) before filter callbacks are destroyed. Typically when stream is being closed | ||
// or filter is being destroyed. | ||
Http::StreamDecoderFilterCallbacks* decode_callback_ = nullptr; | ||
Http::StreamEncoderFilterCallbacks* encode_callback_ = nullptr; | ||
}; | ||
|
||
} // namespace Http | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.