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

Support protobuf separately to GRPCPayload for the client #889

Merged
merged 4 commits into from
Jul 14, 2020

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Jul 14, 2020

Motivation:

To support payloads other than SwiftProtobuf.Message we required that
all messages conform to GRPCPayload. For protobuf messages we added
GRPCProtobufPayload which provides a default implemenation of
GRPCPayload for protobuf messages. We generated this conformance for
all protobuf messages we saw. This lead to a number issues and
workarounds including: #738, #778, #801, #837, #877, #881.

The intention is to continue to support GRPCPayload in addition to
protobuf, however, support for protobuf will not be via the
GRPCProtobufPayload protocol.

This PR builds on #886 by increasing the surface area of the client APIs
so that they are not constrained to GRPCPayload. The surface API now
has variants for GRPCPayload and SwiftProtobuf.Message. Internally
the client deals with serializers and deserializers.

Modifications:

  • GRPCClientChannelHandler and GRPCClientStateMachine are no longer
    generic over a request and response type, rather they deal with the
    serialzed version of requests and response (i.e. ByteBuffers) and
    defer the (de/)serialization to a separate handler.
  • Added GRCPClientCodecHandler to handle (de/)serialization of
    messages
  • Clients are no longer constrained to having their request/response
    payloads conform to GRPCPayload
  • Conformance to GRPCProtobufPayload is no longer generated and the
    protocol is deprecated and has no requirements.
  • Drop the 'GenerateConformance' option from the codegen since it is no
    longer required
  • Reintroduce a filter to the codegen so that we only consider files
    which contain services, this avoids generating empty files
  • Regenerate code where necessary

Result:

  • GRPCProtobufPayload is no longer required

glbrntt added 2 commits July 14, 2020 11:15
Motivation:

To support payloads other than `SwiftProtobuf.Message` we required that
all messages conform to `GRPCPayload`. For protobuf messages we added
`GRPCProtobufPayload` which provides a default implemenation of
`GRPCPayload` for protobuf messages. We generated this conformance for
all protobuf messages we saw. This lead to a number issues and
workarounds including: grpc#738, grpc#778, grpc#801, grpc#837, grpc#877, grpc#881.

The intention is to continue to support `GRPCPayload` in addition to
protobuf, however, support for protobuf will not be via the
`GRPCProtobufPayload` protocol.

This PR builds on grpc#886 by increasing the surface area of the client APIs
so that they are not constrained to `GRPCPayload`. The surface API now
has variants for `GRPCPayload` and `SwiftProtobuf.Message`. Internally
the client deals with serializers and deserializers.

Modifications:

- `GRPCClientChannelHandler` and `GRPCClientStateMachine` are no longer
  generic over a request and response type, rather they deal with the
  serialzed version of requests and response (i.e. `ByteBuffer`s) and
  defer the (de/)serialization to a separate handler.
- Added `GRCPClientCodecHandler` to handle (de/)serialization of
  messages
- Clients are no longer constrained to having their request/response
  payloads conform to `GRPCPayload`
- Conformance to `GRPCProtobufPayload` is no longer generated and the
  protocol is deprecated and has no requirements.
- Drop the 'GenerateConformance' option from the codegen since it is no
  longer required
- Reintroduce a filter to the codegen so that we only consider files
  which contain services, this avoids generating empty files
- Regenerate code where necessary

Result:

- `GRPCProtobufPayload` is no longer required
@glbrntt
Copy link
Collaborator Author

glbrntt commented Jul 14, 2020

The non-generated changes are in: 7a58889

@glbrntt glbrntt added the ⚠️ semver/major Breaks existing public API. label Jul 14, 2020
@glbrntt glbrntt requested a review from Lukasa July 14, 2020 10:19
Sources/GRPC/ClientCalls/BidirectionalStreamingCall.swift Outdated Show resolved Hide resolved
Sources/GRPC/ClientCalls/BidirectionalStreamingCall.swift Outdated Show resolved Hide resolved
Sources/GRPC/ClientCalls/ClientCallTransport.swift Outdated Show resolved Hide resolved
Sources/GRPC/ClientCalls/ClientStreamingCall.swift Outdated Show resolved Hide resolved
Sources/GRPC/ClientCalls/ClientStreamingCall.swift Outdated Show resolved Hide resolved
Sources/GRPC/ClientConnection.swift Outdated Show resolved Hide resolved
Sources/GRPC/FakeChannel.swift Outdated Show resolved Hide resolved
Sources/GRPC/FakeChannel.swift Outdated Show resolved Hide resolved
Sources/GRPC/FakeChannel.swift Outdated Show resolved Hide resolved
Sources/GRPC/FakeChannel.swift Outdated Show resolved Hide resolved
@glbrntt glbrntt requested a review from Lukasa July 14, 2020 11:22
@glbrntt glbrntt merged commit 248f554 into grpc:master Jul 14, 2020
@glbrntt glbrntt deleted the gb-protobuf-client branch July 14, 2020 12:37
@glbrntt glbrntt mentioned this pull request Jul 14, 2020
@glbrntt glbrntt linked an issue Jul 14, 2020 that may be closed by this pull request
glbrntt added a commit to glbrntt/grpc-swift that referenced this pull request Jul 15, 2020
Motivation:

Recent work in grpc#886 and grpc#889 made `GRPCProtobufPayload` redundant. Since
we broke this work into multiple PRs we temporarily dropped support for
custom `GRPCPayload`s on the server. This PR adds that back.

Modifications:

- Add `GRPCPayload` support back to the server by adding the relevant
  call handler factory functions
- Re-enable the custom payload tests
- Add a few more custom payload tests (since they were limited to just
  bidirectional streaming)

Result:

- Clients and servers support `SwiftProtobuf.Message` and `GRPCPayload`
  separately without using `GRPCProtobufPayload` to bridge between them.
glbrntt added a commit that referenced this pull request Jul 15, 2020
Motivation:

Recent work in #886 and #889 made `GRPCProtobufPayload` redundant. Since
we broke this work into multiple PRs we temporarily dropped support for
custom `GRPCPayload`s on the server. This PR adds that back.

Modifications:

- Add `GRPCPayload` support back to the server by adding the relevant
  call handler factory functions
- Re-enable the custom payload tests
- Add a few more custom payload tests (since they were limited to just
  bidirectional streaming)

Result:

- Clients and servers support `SwiftProtobuf.Message` and `GRPCPayload`
  separately without using `GRPCProtobufPayload` to bridge between them.
glbrntt added a commit to glbrntt/grpc-swift that referenced this pull request Nov 27, 2020
Motivation:

Code should only be generated for files listed in the codegen request.
This regressed in grpc#889.

Modifications:

- Drive code generation from files to generate

Result:

Resolves grpc#1057
glbrntt added a commit to glbrntt/grpc-swift that referenced this pull request Nov 27, 2020
Motivation:

Code should only be generated for files listed in the codegen request.
This regressed in grpc#889.

Modifications:

- Drive code generation from files to generate

Result:

Resolves grpc#1057
glbrntt added a commit that referenced this pull request Nov 30, 2020
Motivation:

Code should only be generated for files listed in the codegen request.
This regressed in #889.

Modifications:

- Drive code generation from files to generate

Result:

Resolves #1057
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ semver/major Breaks existing public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support gRPC map
2 participants