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

Wire up the Call objects #1010

Merged

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Oct 23, 2020

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

@glbrntt glbrntt added the 🆕 semver/minor Adds new public API. label Oct 23, 2020
@glbrntt glbrntt requested a review from Lukasa October 23, 2020 13:19
@@ -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<
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

let flush = next == nil

// Make a promise, store the future.
let promise = self.eventLoop.makePromise(of: Void.self)
Copy link
Collaborator

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.

Copy link
Collaborator Author

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`
Copy link
Collaborator

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
@glbrntt glbrntt force-pushed the gb-feature-interceptors-06 branch from d682705 to cc74c63 Compare October 26, 2020 14:22
@glbrntt glbrntt requested a review from Lukasa October 26, 2020 14:22
@glbrntt glbrntt merged commit 27afc9c into grpc:gb-feature-interceptors Oct 26, 2020
@glbrntt glbrntt deleted the gb-feature-interceptors-06 branch October 26, 2020 17:32
glbrntt added a commit that referenced this pull request Oct 29, 2020
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
glbrntt added a commit that referenced this pull request Nov 6, 2020
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
glbrntt added a commit that referenced this pull request Nov 12, 2020
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
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