-
Notifications
You must be signed in to change notification settings - Fork 419
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
Wire up the Call objects #1010
Wire up the Call objects #1010
Conversation
@@ -22,63 +22,60 @@ import NIOHTTP2 | |||
/// | |||
/// Messages should be sent via the `sendMessage` and `sendMessages` methods; the stream of messages | |||
/// must be terminated by calling `sendEnd` to indicate the final message has been sent. | |||
public final class BidirectionalStreamingCall< | |||
public struct BidirectionalStreamingCall< |
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 struct still has reference semantics. It'd be good to clarify that in the doc comment. The same applies to the others.
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.
Ah, yes, that's certainly worth documenting.
Sources/GRPC/ClientCalls/Call.swift
Outdated
let flush = next == nil | ||
|
||
// Make a promise, store the future. | ||
let promise = self.eventLoop.makePromise(of: Void.self) |
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 need a promise on every message? It seems sufficient to attach one to the last message, doesn't it? For streaming protocols like this you'd expect all these writes to fail with the same error.
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.
Hmm, I guess not? I suppose it's technically possible for one write to fail if a handler does something weirdo but practically speaking that's highly unlikely to happen. Let's save some allocations.
@@ -43,6 +43,10 @@ internal final class ClientTransport<Request, Response> { | |||
/// The current state of the transport. | |||
private var state: State = .idle | |||
|
|||
/// A lazy promise for the underlying `Channel`. We'll succeed this when we transition to `active` |
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.
Mild nit, but this promise isn't lazy.
Motivation: We have the new `Call` object and a way to make calls. We should refactory the existing `UnaryCall`, `ClientStreamingCall`, etc. to be wrappers around `Call`. Modifications: - Reimplement the four call types on top of `Call`; these are now implemented as structs. - This required: - some additional awkward logic in `Call` if the users requests the stream `Channel` future - removing requirements from `GRPCChannel` for constructing each call type, and their concrete implementations. This is now done as an extension. Result: - The four call objects are wired up so that they can use interceptors. - Much less boilerplate
d682705
to
cc74c63
Compare
Motivation: We have the new `Call` object and a way to make calls. We should refactory the existing `UnaryCall`, `ClientStreamingCall`, etc. to be wrappers around `Call`. Modifications: - Reimplement the four call types on top of `Call`; these are now implemented as structs. - This required: - some additional awkward logic in `Call` if the users requests the stream `Channel` future - removing requirements from `GRPCChannel` for constructing each call type, and their concrete implementations. This is now done as an extension. Result: - The four call objects are wired up so that they can use interceptors. - Much less boilerplate
Motivation: We have the new `Call` object and a way to make calls. We should refactory the existing `UnaryCall`, `ClientStreamingCall`, etc. to be wrappers around `Call`. Modifications: - Reimplement the four call types on top of `Call`; these are now implemented as structs. - This required: - some additional awkward logic in `Call` if the users requests the stream `Channel` future - removing requirements from `GRPCChannel` for constructing each call type, and their concrete implementations. This is now done as an extension. Result: - The four call objects are wired up so that they can use interceptors. - Much less boilerplate
Motivation: We have the new `Call` object and a way to make calls. We should refactory the existing `UnaryCall`, `ClientStreamingCall`, etc. to be wrappers around `Call`. Modifications: - Reimplement the four call types on top of `Call`; these are now implemented as structs. - This required: - some additional awkward logic in `Call` if the users requests the stream `Channel` future - removing requirements from `GRPCChannel` for constructing each call type, and their concrete implementations. This is now done as an extension. Result: - The four call objects are wired up so that they can use interceptors. - Much less boilerplate
Motivation:
We have the new
Call
object and a way to make calls. We shouldrefactory the existing
UnaryCall
,ClientStreamingCall
, etc. to bewrappers around
Call
.Modifications:
Call
; these are nowimplemented as structs.
Call
if the users requests thestream
Channel
futureGRPCChannel
for constructing each calltype, and their concrete implementations. This is now done as an
extension.
Result: