-
Notifications
You must be signed in to change notification settings - Fork 428
[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
[async-await] Code generation for "simple, but safe" wrapper client calls. #1261
Conversation
callOptions: callOptions | ||
) | ||
return try await withTaskCancellationHandler { | ||
try Task.checkCancellation() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
@glbrntt I rebased now that you merged the other PR. |
f6b1293
to
d53a9d6
Compare
There was a problem hiding this 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)
Sources/GRPC/AsyncAwaitSupport/GRPCClient+AsyncAwaitSupport.swift
Outdated
Show resolved
Hide resolved
Sources/GRPC/AsyncAwaitSupport/GRPCClient+AsyncAwaitSupport.swift
Outdated
Show resolved
Hide resolved
Sources/protoc-gen-grpc-swift/Generator-Client+AsyncAwait.swift
Outdated
Show resolved
Hide resolved
Sources/protoc-gen-grpc-swift/Generator-Client+AsyncAwait.swift
Outdated
Show resolved
Hide resolved
Sources/protoc-gen-grpc-swift/Generator-Client+AsyncAwait.swift
Outdated
Show resolved
Hide resolved
Sources/protoc-gen-grpc-swift/Generator-Client+AsyncAwait.swift
Outdated
Show resolved
Hide resolved
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>
a62c2e9
to
2d1e988
Compare
There was a problem hiding this 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>
@glbrntt wrote:
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" }) |
There was a problem hiding this comment.
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!
There was a problem hiding this 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!
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.