-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
swift: refactor public functionality as precursor to L7 filters (#858)
## Context As part of the work to support platform (Swift/Kotlin) L7 filters, we are updating the public interfaces/functionality of the Envoy Mobile library to combine the concepts of a `StreamEmitter` and `ResponseHandler` into a "stream". ## Goals - Unify the existing response handler and stream emitter types into a single "stream" type that will make it easier to communicate with an underlying filter manager for both outbound requests and inbound responses - Provide guard rails that prevent the consumer from making mistakes, such as setting callback handlers after starting a stream and thus missing updates - Provide a clear interface to the user for creating and starting streams - Focus on the basics (bi-directional streaming support), which will allow for other wrappers to be written in the future (i.e., GRPC, unary, Rx, etc.) - Update interfaces to utilize the new wrapper types introduced on master (`ResponseHeaders`, `RequestHeaders`, etc.) ## Types - `StreamClient`: The publicly exposed interface of `EnvoyEngine`. Provides a function for starting a new stream using Envoy Mobile, and is built using `StreamClientBuilder` - `StreamPrototype`: Type that allows users to set up a stream (providing callbacks, etc.) prior to starting it - `Stream`: Produced by calling `start()` on a `StreamPrototype`, and allows the consumer to send data over the stream and eventually close it - `GRPCClient` / `GRPCStreamPrototype` / `GRPCStream`: Types wrapping the above 3 types, converting the existing gRPC types to utilize the new functionality To start a stream, consumers now do something like this: ```swift let streamClient = try StreamClientBuilder().build() ... ``` ```swift let headers = RequestHeadersBuilder(method: .get, authority: "envoyproxy.io", path: "/test") .addUpstreamHttpProtocol(.http2) .build() streamClient .newStream() .setOnResponseHeaders { ... } .setOnResponseData { ... } .start() .sendHeaders(headers, endStream: false) .sendData(data) .close() ``` ## Tests - Unit tests have been added / updated accordingly. - Sample apps have also been updated (CI validates via "hello world"). ## Notes - A follow-up PR will migrate Android to mirror these - Documentation will be updated separately Signed-off-by: Michael Rebello <[email protected]> Signed-off-by: JP Simard <[email protected]>
- Loading branch information
Showing
49 changed files
with
1,164 additions
and
1,589 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 was deleted.
Oops, something went wrong.
This file was deleted.
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
Oops, something went wrong.