Skip to content

[async-await] Code generation for "simple, but safe" wrapper client calls. #1261

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

Merged
merged 18 commits into from
Sep 16, 2021

Conversation

simonjbeaumont
Copy link
Collaborator

@simonjbeaumont simonjbeaumont commented Sep 11, 2021

This PR adds codegen support for the "simple, but safe wrappers" that were part of the proposal for async/await support, added in #1231.

Codegen has also been re-run for the example Echo service.

callOptions: callOptions
)
return try await withTaskCancellationHandler {
try Task.checkCancellation()
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the right amount of checking for cancellation? This feels like a lot.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well I guess these are all legitimate early exit points. We could omit as many of these as we like, each omission resulting in some different semantics in the presence of cancellation.

We might want to enumerate the things we are OK with happening after a cancellation?

@simonjbeaumont
Copy link
Collaborator Author

@glbrntt I rebased now that you merged the other PR.

@simonjbeaumont simonjbeaumont force-pushed the sb-async-await-wrapper-gen branch from f6b1293 to d53a9d6 Compare September 13, 2021 15:44
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

This broadly looks good. I left a couple of comments inline. Could we also have some very simple tests to exercise these? (You can bootstrap these: https://github.com/grpc/grpc-swift/blob/async-await/Tests/GRPCTests/AsyncAwaitSupport/AsyncIntegrationTests.swift)

@simonjbeaumont
Copy link
Collaborator Author

@glbrntt I see a rebase will be necessary since the merge of #1264. Would you like time to review before that?

Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
@simonjbeaumont simonjbeaumont force-pushed the sb-async-await-wrapper-gen branch from a62c2e9 to 2d1e988 Compare September 16, 2021 10:56
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Cool -- this looks great modulo one nit. There's also an outstanding comment from a previous review:

Could we also have some very simple tests to exercise these? (You can bootstrap these: https://github.com/grpc/grpc-swift/blob/async-await/Tests/GRPCTests/AsyncAwaitSupport/AsyncIntegrationTests.swift)

Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
@simonjbeaumont
Copy link
Collaborator Author

@glbrntt wrote:

Cool -- this looks great modulo one nit. There's also an outstanding comment from a previous review:

Could we also have some very simple tests to exercise these? (You can bootstrap these: https://github.com/grpc/grpc-swift/blob/async-await/Tests/GRPCTests/AsyncAwaitSupport/AsyncIntegrationTests.swift)

Oops, missed this one. Done in 57998ff.

@@ -73,6 +73,13 @@ final class AsyncIntegrationTests: GRPCTestCase {
}
}

func testUnaryWrapper() {
XCTAsyncTest {
let response = try await self.echo.get(.with { $0.text = "hello" })
Copy link
Collaborator

Choose a reason for hiding this comment

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

The 'wrapped' API is so much nicer!

Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Awesome! Thank you Si!

@glbrntt glbrntt added the 🆕 semver/minor Adds new public API. label Sep 16, 2021
@glbrntt glbrntt merged commit c693ebc into grpc:async-await Sep 16, 2021
glbrntt pushed a commit to glbrntt/grpc-swift that referenced this pull request Sep 16, 2021
…alls. (grpc#1261)

This PR adds codegen support for the "simple, but safe wrappers" that were part of the proposal for async/await support, added in grpc#1231.

Codegen has also been re-run for the example Echo service.
glbrntt pushed a commit to glbrntt/grpc-swift that referenced this pull request Sep 16, 2021
…alls. (grpc#1261)

This PR adds codegen support for the "simple, but safe wrappers" that were part of the proposal for async/await support, added in grpc#1231.

Codegen has also been re-run for the example Echo service.
glbrntt pushed a commit that referenced this pull request Sep 16, 2021
…alls. (#1261)

This PR adds codegen support for the "simple, but safe wrappers" that were part of the proposal for async/await support, added in #1231.

Codegen has also been re-run for the example Echo service.
glbrntt pushed a commit that referenced this pull request Nov 26, 2021
…alls. (#1261)

This PR adds codegen support for the "simple, but safe wrappers" that were part of the proposal for async/await support, added in #1231.

Codegen has also been re-run for the example Echo service.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants