Skip to content

ios: implement gRPC & add tests#416

Merged
rebello95 merged 25 commits intomasterfrom
grpc-wip
Sep 12, 2019
Merged

ios: implement gRPC & add tests#416
rebello95 merged 25 commits intomasterfrom
grpc-wip

Conversation

@rebello95
Copy link
Copy Markdown
Contributor

@rebello95 rebello95 commented Sep 6, 2019

Implements the gRPC protocol on top of the existing Envoy Mobile interfaces, allowing for easily sending gRPC requests over Envoy.

Note: The GRPCResponseHandler isn't kept in memory by the library (similarly to ResponseHandler) - only its closures are passed down to the core. Thus, no state is stored on the handler, and the necessary data is kept in memory by the closures capturing it.

Throughout the buffering function, we're currently copying some data by doing append calls. This may be optimized further in the future.

This PR also includes a set of tests for this new functionality.

Example of sending a gRPC request:

let handler = GRPCResponseHandler(queue: .main)
    .onHeaders { headers, grpcStatus, _ in
        print("gRPC status: \(grpcStatus), headers: \(headers)")
    }
    .onMessage { messageData, _ in
        print("Got message over gRPC: \(messageData)")
    }
    .onError { error in
        print("gRPC failed with error: \(error)")
    }

let requestBuilder = GRPCRequestBuilder(path: "/pb.api.v1.foo.Bar/Baz",
                                        authority: "api.foo.com")
let emitter = GRPCClient(httpClient: envoy).send(requestBuilder.build(), handler: handler)
emitter.sendMessage(someProtoMessage.serializedData())
...

Risk Level: Low (new feature)
Testing: Unit tests, tested locally

Signed-off-by: Michael Rebello me@michaelrebello.com

Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
@rebello95 rebello95 changed the title WIP: implement gRPC ios: implement gRPC with tests Sep 10, 2019
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
@rebello95 rebello95 marked this pull request as ready for review September 10, 2019 23:43
@rebello95 rebello95 changed the title ios: implement gRPC with tests ios: implement gRPC & add tests Sep 10, 2019
buildbreaker
buildbreaker previously approved these changes Sep 11, 2019
Copy link
Copy Markdown

@buildbreaker buildbreaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that we're explicitly exposing some decorative objects for interacting with Envoy in a Grpc manner

Signed-off-by: Michael Rebello <me@michaelrebello.com>
buildbreaker
buildbreaker previously approved these changes Sep 11, 2019
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
buildbreaker
buildbreaker previously approved these changes Sep 11, 2019
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
@rebello95 rebello95 requested a review from goaway September 12, 2019 06:41
Signed-off-by: Michael Rebello <me@michaelrebello.com>
@rebello95
Copy link
Copy Markdown
Contributor Author

Thanks for the review and offline discussions, @goaway! Ready for another look.

Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Copy link
Copy Markdown
Contributor

@goaway goaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, nice work!

@rebello95
Copy link
Copy Markdown
Contributor Author

Thanks for the review @goaway!

@rebello95 rebello95 merged commit f77954e into master Sep 12, 2019
@rebello95 rebello95 deleted the grpc-wip branch September 12, 2019 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants