-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
listener: first implementation of an Api Listener (#9516)
Description: this PR introduces the initial implementation of an Api Listener based on the proto configuration merged in #8170. Notably, this PR introduces the ability to add only _one_ api listener via _bootstrap config only_. This decision was made in order to iterate into more complex setups (multiple listeners, LDS supplied listeners) in subsequent PRs. Moreover, the API listener is created in the context of Envoy's main thread not worker threads. A first use of this Api Listener can be seen in envoyproxy/envoy-mobile#616. Risk Level: low, only used in Envoy Mobile. The risk here is about building something generally useful and flexible. Note however that a couple of things were rejiggered in the HCM. Testing: unit and integration tests. Additional testing in https://github.com/lyft/envoy-mobile. Docs Changes: Added inline comments and TODOs. Proto documentation is up-to-date. Release Notes: similar to doc changes. Signed-off-by: Jose Nino <[email protected]>
- Loading branch information
Showing
36 changed files
with
1,053 additions
and
39 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 1 addition & 2 deletions
3
generated_api_shadow/envoy/config/listener/v2/api_listener.proto
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 1 addition & 2 deletions
3
generated_api_shadow/envoy/config/listener/v3/api_listener.proto
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include "envoy/http/codec.h" | ||
|
||
namespace Envoy { | ||
namespace Http { | ||
|
||
/** | ||
* ApiListener that allows consumers to interact with HTTP streams via API calls. | ||
*/ | ||
// TODO(junr03): this is a replica of the functions in ServerConnectionCallbacks. It would be nice | ||
// to not duplicate this interface layout. | ||
class ApiListener { | ||
public: | ||
virtual ~ApiListener() = default; | ||
|
||
/** | ||
* Invoked when a new request stream is initiated by the remote. | ||
* @param response_encoder supplies the encoder to use for creating the response. The request and | ||
* response are backed by the same Stream object. | ||
* @param is_internally_created indicates if this stream was originated by a | ||
* client, or was created by Envoy, by example as part of an internal redirect. | ||
* @return StreamDecoder& supplies the decoder callbacks to fire into for stream decoding events. | ||
*/ | ||
virtual StreamDecoder& newStream(StreamEncoder& response_encoder, | ||
bool is_internally_created = false) PURE; | ||
}; | ||
|
||
using ApiListenerPtr = std::unique_ptr<ApiListener>; | ||
using ApiListenerOptRef = absl::optional<std::reference_wrapper<ApiListener>>; | ||
|
||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "envoy/http/api_listener.h" | ||
|
||
namespace Envoy { | ||
namespace Server { | ||
|
||
/** | ||
* Listener that allows consumer to interact with Envoy via a designated API. | ||
*/ | ||
class ApiListener { | ||
public: | ||
enum class Type { HttpApiListener }; | ||
|
||
virtual ~ApiListener() = default; | ||
|
||
/** | ||
* An ApiListener is uniquely identified by its name. | ||
* | ||
* @return the name of the ApiListener. | ||
*/ | ||
virtual absl::string_view name() const PURE; | ||
|
||
/** | ||
* @return the Type of the ApiListener. | ||
*/ | ||
virtual Type type() const PURE; | ||
|
||
/** | ||
* @return valid ref IFF type() == Type::HttpApiListener, otherwise nullopt. | ||
*/ | ||
virtual Http::ApiListenerOptRef http() PURE; | ||
}; | ||
|
||
using ApiListenerPtr = std::unique_ptr<ApiListener>; | ||
using ApiListenerOptRef = absl::optional<std::reference_wrapper<ApiListener>>; | ||
|
||
} // namespace Server | ||
} // 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
Oops, something went wrong.