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
Add support for gRPC using SwiftNIO #121
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR introduces support for the vanilla gRPC protocol by providing a new
ConnectNIO
library which utilizesSwiftNIO
(which provides support for trailers) to expose a new.grpc
extension onNetworkProtocol
.Note that this new library is not available through CocoaPods because SwiftNIO no longer supports CocoaPods.
Details
SwiftNIO
, a newConnectNIO
module is being introduced alongside the existingConnect
module. This means that existing Connect/gRPC-Web users do not need to include this new dependency.NIOHTTPClient
type which wrapsSwiftNIO
concepts and conforms toConnect.HTTPClientInterface
.ConnectNIO
module also contains logic to support gRPC, which is exposed as an extension onNetworkProtocol
(demonstrated below).ConnectNIO
and replacingURLSessionHTTPClient
usage withNIOHTTPClient
.Example
The Eliza Swift Package Manager example has been updated to include support for gRPC using the
NIOHTTPClient
. Using gRPC with generated Connect clients is as easy as adding an import and making a 2-line change:Binary size impact
There is no binary size impact on clients that only include the
Connect
library. When includingConnectNIO
,SwiftNIO
dependencies get compiled in, resulting in a ~2.1MB increase on an unstripped.ipa
. For example:Connect
: 699KBConnectNIO
: 2.8MBTesting
The suite of crosstests has been updated to run a matrix of tests which include:
URLSessionHTTPClient
&NIOHTTPClient
)URLSessionHTTPClient
&NIOHTTPClient
)NIOHTTPClient
)