-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
quic: splitting into client and server #24513
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
#include "source/common/quic/client_codec_impl.h" | ||
|
||
#include "source/common/quic/envoy_quic_client_stream.h" | ||
|
||
namespace Envoy { | ||
namespace Quic { | ||
|
||
// Converts a QuicStream instance to EnvoyQuicStream instance. The current stream implementation | ||
// inherits from these two interfaces, with the former one providing Quic interface and the latter | ||
// providing Envoy interface. | ||
EnvoyQuicClientStream* quicStreamToEnvoyClientStream(quic::QuicStream* stream) { | ||
return dynamic_cast<EnvoyQuicClientStream*>(stream); | ||
} | ||
|
||
QuicHttpClientConnectionImpl::QuicHttpClientConnectionImpl( | ||
EnvoyQuicClientSession& session, Http::ConnectionCallbacks& callbacks, | ||
Http::Http3::CodecStats& stats, | ||
const envoy::config::core::v3::Http3ProtocolOptions& http3_options, | ||
const uint32_t max_request_headers_kb, const uint32_t max_response_headers_count) | ||
: QuicHttpConnectionImplBase(session, stats), quic_client_session_(session) { | ||
session.setCodecStats(stats); | ||
session.setHttp3Options(http3_options); | ||
session.setHttpConnectionCallbacks(callbacks); | ||
session.setMaxIncomingHeadersCount(max_response_headers_count); | ||
session.set_max_inbound_header_list_size(max_request_headers_kb * 1024); | ||
} | ||
|
||
void QuicHttpClientConnectionImpl::goAway() { | ||
quic_client_session_.SendHttp3GoAway(quic::QUIC_PEER_GOING_AWAY, "client goaway"); | ||
} | ||
|
||
Http::RequestEncoder& | ||
QuicHttpClientConnectionImpl::newStream(Http::ResponseDecoder& response_decoder) { | ||
EnvoyQuicClientStream* stream = | ||
quicStreamToEnvoyClientStream(quic_client_session_.CreateOutgoingBidirectionalStream()); | ||
ASSERT(stream != nullptr, "Fail to create QUIC stream."); | ||
stream->setResponseDecoder(response_decoder); | ||
if (quic_client_session_.aboveHighWatermark()) { | ||
stream->runHighWatermarkCallbacks(); | ||
} | ||
return *stream; | ||
} | ||
|
||
void QuicHttpClientConnectionImpl::onUnderlyingConnectionAboveWriteBufferHighWatermark() { | ||
quic_client_session_.PerformActionOnActiveStreams([](quic::QuicStream* quic_stream) { | ||
ENVOY_LOG(debug, "runHighWatermarkCallbacks on stream {}", quic_stream->id()); | ||
quicStreamToEnvoyClientStream(quic_stream)->runHighWatermarkCallbacks(); | ||
return true; | ||
}); | ||
} | ||
|
||
void QuicHttpClientConnectionImpl::onUnderlyingConnectionBelowWriteBufferLowWatermark() { | ||
quic_client_session_.PerformActionOnActiveStreams([](quic::QuicStream* quic_stream) { | ||
ENVOY_LOG(debug, "runLowWatermarkCallbacks on stream {}", quic_stream->id()); | ||
quicStreamToEnvoyClientStream(quic_stream)->runLowWatermarkCallbacks(); | ||
return true; | ||
}); | ||
} | ||
|
||
} // namespace Quic | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include "envoy/http/codec.h" | ||
#include "envoy/registry/registry.h" | ||
|
||
#include "source/common/common/assert.h" | ||
#include "source/common/common/logger.h" | ||
#include "source/common/quic/codec_impl.h" | ||
#include "source/common/quic/envoy_quic_client_session.h" | ||
|
||
namespace Envoy { | ||
namespace Quic { | ||
|
||
class QuicHttpClientConnectionImpl : public QuicHttpConnectionImplBase, | ||
public Http::ClientConnection { | ||
public: | ||
QuicHttpClientConnectionImpl(EnvoyQuicClientSession& session, | ||
Http::ConnectionCallbacks& callbacks, Http::Http3::CodecStats& stats, | ||
const envoy::config::core::v3::Http3ProtocolOptions& http3_options, | ||
const uint32_t max_request_headers_kb, | ||
const uint32_t max_response_headers_count); | ||
|
||
// Http::ClientConnection | ||
Http::RequestEncoder& newStream(Http::ResponseDecoder& response_decoder) override; | ||
|
||
// Http::Connection | ||
void goAway() override; | ||
void shutdownNotice() override {} | ||
void onUnderlyingConnectionAboveWriteBufferHighWatermark() override; | ||
void onUnderlyingConnectionBelowWriteBufferLowWatermark() override; | ||
|
||
private: | ||
EnvoyQuicClientSession& quic_client_session_; | ||
}; | ||
|
||
} // namespace Quic | ||
} // 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no source/common/http/codec_server.cc to correspond to this current file? I guess not. How come?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the client side of Envoy, creating upstream QUIC clients :-P
The server bits are in the HCM, and I turned that into factory code to avoid the direct dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, yeah I get that this particular file (codec_client.cc) is for making upstream connections. But I guess I kinda expected there to be some sort of server-side analog in this directory too. (Like how we have QuicSpdyServerStream vs QuicSpdyClientStream in QUICHE). But I guess, as you say, that's all in the HCM. Fascinating. Thanks!