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

Initial upload of a GRPC implementation for Helidon #259

Merged
merged 52 commits into from
Sep 19, 2024
Merged

Conversation

rbair23
Copy link
Member

@rbair23 rbair23 commented May 29, 2024

This PR introduces a new module, pbj-grpc-helidon. This is a Helidon specific module (for version 4.0.8+) that provides the glue between HTTP2 (implemented by Helidon) and PBJ service endpoints (generated by PBJ based on a service definition in the protobuf schema files).

This PR does not introduce changes to the compiler to generate service interfaces or stubs. Rather, it assumes some other PR will do that, and it focuses on defining the runtime API and the Helidon module. Changes to the compiler will be done by #255.

In this PR:

  • The build is upgraded to Java 21. The consensus node uses Java 21, as does Helidon.
  • The module pbj-grpc-helidon is added
  • The module pbj-grpc-helidon-config is added
  • The interface ServiceInterface is added to pbj-runtime along with other gRPC interfaces

gRPC

gRPC is an HTTP2-based protocol for message passing. The specification and the documentation show how this is done. Both application/grpc+proto (protobuf based messages) and application/grpc+json (JSON-encoded protobuf) are supported.

A separate specification for web-grpc exists, but is not supported by this PR.

pbj-grpc-helidon

Public API in this module used directly by users include PbjRouting, and GrpcStatus.

Public API in this module used by Helidon directly include PbjProtocolSelector, PbjProtocolProvider, PbjProtocolConfigProvider, and PbjConfig.

All other entities are private to the module.

Design

Helidon uses the ServiceLoader to identify the ProtocolConfigProvider (used for configuration) and the Http2SubProtocolProvider to delegate HTTP2 calls to. Our implementation of Http2SubProtocolProvider, PbjProtocolProvider, is simply used to create (based on some provided configuration) the Http2SubProtocolSelector. This selector is where all the real works happens. For this module, that is PbjProtocolSelector.

If you look into the PbjProtocolSelector, you will find the subProtocol method. This method is called by Helidon. It is the main entry point for handling HTTP2 routes supported by this system. After some preliminary checks, it delegates to a "handler" (PbjErrorProtocolHandler or PbjProtocolHandler) to handle appropriate details (reading from and writing to HTTP2 streams).

The PbjProtocolHandler will delegate to a ServiceInterface to handle a particular method invocation, in such a way as to avoid all reflection. It provides a callback to the ServiceInterface through which the ServiceInterface can send start a request, stream messages, and close a request. The implementation of this callback handles all the glue with HTTP2.

That is, the classes in pbj-grpc-helidon are the glue between the HTTP code of Helidon (that knows nothing about gRPC or PBJ), and the PBJ ServiceInterfaces, which know nothing about HTTP2.

@rbair23 rbair23 linked an issue May 29, 2024 that may be closed by this pull request
@jsync-swirlds
Copy link
Member

A couple questions we should probably answer in the documentation for this PR:
What is the advantage of this approach over the existing Helidon gRPC implementation?
Could (or does) this work leverage the Helidon implementation to reduce the amount we must build ourselves?

@rbair23
Copy link
Member Author

rbair23 commented May 29, 2024

A couple questions we should probably answer in the documentation for this PR: What is the advantage of this approach over the existing Helidon gRPC implementation? Could (or does) this work leverage the Helidon implementation to reduce the amount we must build ourselves?

@jsync-swirlds, I'll add these to the issue itself (since it is more about the motivation rather than the solution)

@rbair23
Copy link
Member Author

rbair23 commented May 29, 2024

Could (or does) this work leverage the Helidon implementation to reduce the amount we must build ourselves?

I have put a message on their issue: helidon-io/helidon#5418. I will try to create a PR for Helidon that creates the right abstraction for us, such that our module could be truly minimal and hopefully avoid having to duplicate any work with what they're doing.

Copy link

github-actions bot commented Jun 27, 2024

JUnit Test Report

   66 files  +11     66 suites  +11   2m 18s ⏱️ -1s
1 244 tests +43  1 241 ✅ +42   3 💤 +1  0 ❌ ±0 
7 099 runs  +43  7 080 ✅ +42  19 💤 +1  0 ❌ ±0 

Results for commit 1aed82c. ± Comparison against base commit aa12028.

This pull request removes 8 and adds 50 tests. Note that renamed tests count towards both.
, 1
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [1] FLOAT, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc30ab00@4ae49387, [0.1, 0.5, 100.0], 12, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc30ad18@6abb7b7d
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [1] STRING, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc31d098@4db728df, [string 1, testing here, testing there], com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc31d2b0@b0d3e7
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [2] BYTES, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc31d4c8@7cdfa824, [010203, ff7f0f, 42da07370bff], com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc31d6e0@18db3b3c
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [2] DOUBLE, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc30af30@7f2c995b, [0.1, 0.5, 100.0, 1.7653472635472653E240], 32, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc30b148@101c15ad
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [3] BOOL, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc30b360@6068ebb2, [true, false, false, true, true, true], 6, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc30b578@5a466dd
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [4] ENUM, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc30b790@1ed9d173, [Mock for EnumWithProtoMetadata, hashCode: 347436335, Mock for EnumWithProtoMetadata, hashCode: 1592970214, Mock for EnumWithProtoMetadata, hashCode: 644718663], 3, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00007f45fc30b9a8@298e002d
com.hedera.pbj.runtime.Utf8ToolsTest ‑ [4] 
com.hedera.pbj.grpc.helidon.PbjTest$BidiStreamingTests ‑ streamingBidi()
com.hedera.pbj.grpc.helidon.PbjTest$CompressionTests ‑ [1] gzip
com.hedera.pbj.grpc.helidon.PbjTest$CompressionTests ‑ [2] deflate
com.hedera.pbj.grpc.helidon.PbjTest$CompressionTests ‑ [3] random
com.hedera.pbj.grpc.helidon.PbjTest$CompressionTests ‑ identityIfNotSpecified()
com.hedera.pbj.grpc.helidon.PbjTest$CompressionTests ‑ identityIfSpecified()
com.hedera.pbj.grpc.helidon.PbjTest$ConcurrencyTests ‑ manyConcurrentUnaryCalls()
com.hedera.pbj.grpc.helidon.PbjTest$ContentTypeTests ‑ [1] application/grpc+proto
com.hedera.pbj.grpc.helidon.PbjTest$ContentTypeTests ‑ [2] application/grpc
com.hedera.pbj.grpc.helidon.PbjTest$ContentTypeTests ‑ contentTypeCanBeCustom()
…

♻️ This comment has been updated with latest results.

Copy link
Contributor

codacy-production bot commented Jun 27, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-3.59% (target: -1.00%) 6.70%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (6da76df) 4361 1977 45.33%
Head commit (d5f5caa) 4779 (+418) 1995 (+18) 41.75% (-3.59%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#259) 537 36 6.70%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences


🚀 Don’t miss a bit, follow what’s new on Codacy.

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Copy link

github-actions bot commented Jun 27, 2024

Integration Test Report

    289 files  ±0      289 suites  ±0   9m 13s ⏱️ +33s
103 729 tests ±0  103 729 ✅ ±0  0 💤 ±0  0 ❌ ±0 
103 957 runs  ±0  103 957 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 1aed82c. ± Comparison against base commit aa12028.

This pull request removes 3 and adds 3 tests. Note that renamed tests count towards both.
com.hedera.pbj.intergration.test.ParserNeverWrapsTest ‑ [1] com.hedera.pbj.intergration.test.ParserNeverWrapsTest$$Lambda/0x00007f05fc49f2d0@67c22d78
com.hedera.pbj.intergration.test.ParserNeverWrapsTest ‑ [2] com.hedera.pbj.intergration.test.ParserNeverWrapsTest$$Lambda/0x00007f05fc49f508@46fb22b5
com.hedera.pbj.intergration.test.ParserNeverWrapsTest ‑ [3] com.hedera.pbj.intergration.test.ParserNeverWrapsTest$$Lambda/0x00007f05fc49f740@4902c6e9
com.hedera.pbj.intergration.test.ParserNeverWrapsTest ‑ [1] com.hedera.pbj.intergration.test.ParserNeverWrapsTest$$Lambda/0x00007fea644e2008@a5f66be
com.hedera.pbj.intergration.test.ParserNeverWrapsTest ‑ [2] com.hedera.pbj.intergration.test.ParserNeverWrapsTest$$Lambda/0x00007fea644e2240@7978a822
com.hedera.pbj.intergration.test.ParserNeverWrapsTest ‑ [3] com.hedera.pbj.intergration.test.ParserNeverWrapsTest$$Lambda/0x00007fea644e2478@7eafc404

♻️ This comment has been updated with latest results.

@rbair23 rbair23 marked this pull request as ready for review June 27, 2024 19:20
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
…e Service Interface.

New Pipelines class with all the Flow.* work and a fluent API for
building out the handling pipeline.

Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
…e Service Interface.

New Pipelines class with all the Flow.* work and a fluent API for
building out the handling pipeline.

Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
…notation processors

Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: Richard Bair <rbair23@users.noreply.github.com>
Signed-off-by: litt <austin@swirldslabs.com>
Signed-off-by: litt <austin@swirldslabs.com>
Signed-off-by: litt <austin@swirldslabs.com>
Signed-off-by: litt <austin@swirldslabs.com>
@litt3 litt3 marked this pull request as draft September 18, 2024 14:43
@litt3 litt3 self-assigned this Sep 18, 2024
Signed-off-by: litt <austin@swirldslabs.com>
Signed-off-by: litt <austin@swirldslabs.com>
Signed-off-by: litt <austin@swirldslabs.com>
Signed-off-by: litt <austin@swirldslabs.com>
Signed-off-by: litt <austin@swirldslabs.com>
@litt3 litt3 marked this pull request as ready for review September 18, 2024 18:36
@rbair23 rbair23 merged commit 61765cc into main Sep 19, 2024
6 checks passed
@rbair23 rbair23 deleted the 00257-helidon-grpc branch September 19, 2024 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add gRPC module for Helidon
5 participants