Skip to content
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

ios: finish bridging between ObjC/Swift #312

Merged
merged 33 commits into from
Aug 20, 2019
Merged

ios: finish bridging between ObjC/Swift #312

merged 33 commits into from
Aug 20, 2019

Conversation

rebello95
Copy link
Contributor

@rebello95 rebello95 commented Jul 30, 2019

This PR ties together the upstream Objective-C/++ implementation with the Swift interfaces/bridging implementation. After this change, end-to-end calls from the native Swift library into the Envoy core should be supported.

  • Implements the streaming and unary request methods
  • Adds a simple EnvoyStreamEmitter which sends requests from Swift down into Objective-C
  • Updates the header conversion functions and their tests to convert to the proper types ([String: [String]] versus [String: String])
  • Implements ResponseHandler as a class which provides a pass-through for setting Objective-C blocks directly from Swift for handling responses
  • Adds a parser for status codes, as well as tests

#349 will use this interface with the Swift demo apps.

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

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

stale bot commented Aug 7, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale label Aug 7, 2019
@rebello95
Copy link
Contributor Author

Waiting on #316

@stale stale bot removed the stale label Aug 7, 2019
Signed-off-by: Michael Rebello <me@michaelrebello.com>
@stale
Copy link

stale bot commented Aug 15, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale label Aug 15, 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>
@stale stale bot removed the stale label Aug 16, 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>
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>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: Michael Rebello <me@michaelrebello.com>
@rebello95 rebello95 changed the title WIP: bridge Objective-C/Swift layers ios: finish bridging between ObjC/Swift Aug 20, 2019
@rebello95 rebello95 marked this pull request as ready for review August 20, 2019 00:33
Signed-off-by: Michael Rebello <me@michaelrebello.com>
return EnvoyStreamEmitter(stream: httpStream)
}

public func sendUnary(_ request: Request, body: Data?,
Copy link
Contributor

@goaway goaway Aug 20, 2019

Choose a reason for hiding this comment

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

Instead of startStream and sendUnary, I'd suggest:
send(request:handler:) and send(request:body:handler:)

Copy link
Contributor

Choose a reason for hiding this comment

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

or sendRequest(_:handler:) / sendRequest(_:body:handler:)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather lean towards being clear on the intent (stream/unary) for the end consumer's sake, rather than making them assume based on function parameter signatures

Copy link
Contributor

Choose a reason for hiding this comment

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

And of course trailers can be in there too, but since trailers are so rare in normal cases, I'd probably still suggest a signature which excludes or defaults them.

Copy link
Contributor

@goaway goaway Aug 20, 2019

Choose a reason for hiding this comment

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

I understand the argument about clarity/specificity, but I doubt most end-users are likely to be thinking in these terms, and I have misgivings because I don't really think this actually is more accurate.

The startStream interface is a perfectly appropriate interface for sending a "unary" request, and the current naming sort of makes it sound like you should only use it when you're trying to stream something (a naive user might even think that this is to stream a response, which is completely unrelated).

In fact, all HTTP requests are "unary" in the sense that they have a single request and response. I feel like these are semi-GRPC concepts that are leaking in because GRPC layers a stream encoding into a "unary" HTTP request.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess in general, since this is a top level interface, I'm pushing back a little because I feel the naming should be recognizable and understandable to users who don't have a deep familiarity with the underlying concerns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Talked offline - this makes sense. Going to update in a separate PR after merging this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
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.

This looks great, nice work!

@rebello95 rebello95 merged commit cb7c0e1 into master Aug 20, 2019
@rebello95 rebello95 deleted the objc-bridging branch August 20, 2019 18:22
rebello95 added a commit that referenced this pull request Aug 20, 2019
**This is a working end-to-end iOS implementation using Envoy Mobile as a library!**

Depends on #312 and #353.

Updates our Swift example app to use the Envoy Mobile direct interfaces rather than using `URLSession` and Envoy as a listener.

Note: For now, we are no longer showing the text response of the response body due to the fact that the underlying implementation is not yet complete for bodied requests (headers-only).

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

![Simulator Screen Shot - TestDevice - 2019-08-20 at 13 57 44](https://user-images.githubusercontent.com/2643476/63383898-8f466280-c352-11e9-8c2e-944efda59ea2.png)
rebello95 added a commit that referenced this pull request Aug 20, 2019
Per the discussion [here](#312 (comment)), updating the unary and streaming interfaces.

Also moving the non-streaming convenience function into an extension on the protocol type so that it's available to all consumers.

Lastly, added a test to validate the default behavior of this extension function.

Signed-off-by: Michael Rebello <me@michaelrebello.com>
rebello95 added a commit that referenced this pull request Aug 20, 2019
Per the discussion [here](#312 (comment)), updating the unary and streaming interfaces.

- Moved the non-streaming convenience function into an extension on the protocol type so that it's available to all consumers
- Added a test to validate the default behavior of this extension function
- Added a `CancelableStream` protocol which includes a subset of functionality from the `StreamEmitter`, allowing consumers of the unary function to cancel requests without having the ability to send additional data into the stream

Signed-off-by: Michael Rebello <me@michaelrebello.com>
jpsim pushed a commit to envoyproxy/envoy that referenced this pull request Nov 28, 2022
**This is a working end-to-end iOS implementation using Envoy Mobile as a library!**

Depends on envoyproxy/envoy-mobile#312 and envoyproxy/envoy-mobile#353.

Updates our Swift example app to use the Envoy Mobile direct interfaces rather than using `URLSession` and Envoy as a listener.

Note: For now, we are no longer showing the text response of the response body due to the fact that the underlying implementation is not yet complete for bodied requests (headers-only).

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

![Simulator Screen Shot - TestDevice - 2019-08-20 at 13 57 44](https://user-images.githubusercontent.com/2643476/63383898-8f466280-c352-11e9-8c2e-944efda59ea2.png)

Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit to envoyproxy/envoy that referenced this pull request Nov 28, 2022
Per the discussion [here](envoyproxy/envoy-mobile#312 (comment)), updating the unary and streaming interfaces.

- Moved the non-streaming convenience function into an extension on the protocol type so that it's available to all consumers
- Added a test to validate the default behavior of this extension function
- Added a `CancelableStream` protocol which includes a subset of functionality from the `StreamEmitter`, allowing consumers of the unary function to cancel requests without having the ability to send additional data into the stream

Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit to envoyproxy/envoy that referenced this pull request Nov 29, 2022
**This is a working end-to-end iOS implementation using Envoy Mobile as a library!**

Depends on envoyproxy/envoy-mobile#312 and envoyproxy/envoy-mobile#353.

Updates our Swift example app to use the Envoy Mobile direct interfaces rather than using `URLSession` and Envoy as a listener.

Note: For now, we are no longer showing the text response of the response body due to the fact that the underlying implementation is not yet complete for bodied requests (headers-only).

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

![Simulator Screen Shot - TestDevice - 2019-08-20 at 13 57 44](https://user-images.githubusercontent.com/2643476/63383898-8f466280-c352-11e9-8c2e-944efda59ea2.png)

Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit to envoyproxy/envoy that referenced this pull request Nov 29, 2022
Per the discussion [here](envoyproxy/envoy-mobile#312 (comment)), updating the unary and streaming interfaces.

- Moved the non-streaming convenience function into an extension on the protocol type so that it's available to all consumers
- Added a test to validate the default behavior of this extension function
- Added a `CancelableStream` protocol which includes a subset of functionality from the `StreamEmitter`, allowing consumers of the unary function to cancel requests without having the ability to send additional data into the stream

Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: JP Simard <jp@jpsim.com>
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.

3 participants