-
Notifications
You must be signed in to change notification settings - Fork 428
This week's improvements #184
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
Conversation
Requires the CocodaPods 'xcodeproj' gem.
…ally usable in tests.
3c87e6b
to
2f93962
Compare
Nice! I've been struggling to switch indentation settings every time I switch projects. I really hope Xcode projects could embed/store a custom indentation configuration. |
They can, but |
ca0d255
to
ee99455
Compare
The expected behavior is now for the client call's completion handler to be called when the whole call is completed. You can check that completion handler's `statusCode` for the call's result. The intermediate send/receive call completion handlers will also get called with an error, but that error's status code is most likely to be `.unknown` (because send/receive calls don't receive the final status from the server). In addition, `CallResult` now also includes the operation group's success flag, but that flag is much less important now. This includes: - Make most completion handlers non-throwing (their errors were for the most part discarded, anyway) - Extract Receive-Streaming into a common protocol - Changing many completion handler interfaces to be called with a `CallResult` instead of `Data?` and `ResultOrRPCError<ReceivedType?>` instead of `(ReceivedType, Error)` - Not throwing on end of stream, but passing `nil` to the completion handler instead - Making `ServerSessionUnary` always return an error when one of its calls fail - Adding test to ensure the proper error behavior.
ee99455
to
ac7979d
Compare
- avoid starting the server in an asynchronous block (as that can lead to it being shut down too early) - make sure to close bidirectional calls - wait on _all_ `receiveMessage` calls in `handleBiDiStream`. Previously, we would not wait for the first `receiveMessage` call, which could lead to race conditions.
…ers could get called twice, as well as an unsynchronized access to `CompletionQueue.operationGroups` that should be synchronized.
…dentation settings when running `make`.
…g `Call` equivalents as possible, so that only server-specific methods are left in `Handler`.
… receiving SHUTDOWN still have their completion handlers called.
…I had forgotten that sending initial metadata is required).
e786079
to
d25d0c5
Compare
05b7633
to
ad6973c
Compare
…nectionFailureTests".
ad6973c
to
0985a47
Compare
This should be ready to review now. Will look into the CI failures soon. |
…thods actually *move* the metadata (so a second call to these methods would previously always return empty metadata objects).
91d7d0e
to
c962004
Compare
Closing and re-opening to measure the effects of the dependency cache... |
e0026f4
to
bd29ef6
Compare
…, for faster CI builds. (Also separate the dependency resolution and main build steps into separate steps, so we can time each one individually.)
bd29ef6
to
9c54d0a
Compare
We need to return status OK here, as it seems like the server might never send out the last few messages once it has been asked to send a non-OK status. Alternatively, we could send a non-OK status here, but then we would need to sleep for a few milliseconds before sending the non-OK status.
…r code. These tests don't really test the logic of the SwiftGRPC library, but are meant as an example of how one would go about testing their own client/server code that relies on SwiftGRPC.
…tus without a result.
Also changes a few method signatures where passing a `CallResult` does not make sense.
7516d8d
to
5d32204
Compare
Makefile
Outdated
@@ -8,6 +8,8 @@ all: | |||
|
|||
project: | |||
swift package generate-xcodeproj | |||
# Optional: set the generated project's indentation settings. |
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.
Let's add a comment here to explain how to install the gem. I think it's safe to assume people will have ruby installed, but sudo gem install xcodeproj
might not be obvious to non-rubyists.
@@ -23,15 +23,15 @@ let package = Package( | |||
.library(name: "SwiftGRPC", targets: ["SwiftGRPC"]), | |||
], | |||
dependencies: [ | |||
.package(url: "https://github.com/Zewo/zlib.git", from: "0.4.0"), | |||
.package(url: "https://github.com/apple/swift-nio-zlib-support.git", from: "1.0.0"), |
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.
I'm not hugely-confident that this project won't move, but since the zewo version was deprecated, I'm ok with this.
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.
Do we have tests that verify this now?
"Ensure that any operation groups enqueued on a completion queue after receiving SHUTDOWN still have their completion handlers called"
Thanks for all these improvements! See a few minor comments above, but overall it looks great. |
As discussed via Hangouts with @timburks, I'm going to gather all my changes for this week in this PR, then have them merged at once.
Notable changes:
zlib
module instead of a vendored one.gRPCTests
to make them less flaky (before, they would still flake out from time to time on my machine).send
andreceive
homogenous across all stream-sending/receiving client and server calls.session.sendAndClose(response: response, status: .ok, completion: .nil)
instead of justsession.sendAndClose(response)
, because methods in protocols can't have default arguments. If you prefer, I could add another method to the protocols for the "default" case (status OK, no completion handler) in lieu of default arguments.FYI, the increase in lines is almost exclusively due to tests.
Also, I tried to keep the number of commits reasonable, but there is just a lot of stuff in this PR.