Skip to content

grpc: implement Handle for servers and remove old Service abstraction#2536

Merged
dfawley merged 5 commits intohyperium:masterfrom
dfawley:generic_api3
Mar 9, 2026
Merged

grpc: implement Handle for servers and remove old Service abstraction#2536
dfawley merged 5 commits intohyperium:masterfrom
dfawley:generic_api3

Conversation

@dfawley
Copy link
Copy Markdown
Collaborator

@dfawley dfawley commented Mar 4, 2026

Note: This PR is based on top of #2528, so review can wait until after that is approved (or close to ready).

Also:

  • Update inmemory example to use new abstractions.
  • Remove multiaddr example; update inmemory example to handle multiple addresses instead (there was a lot of code duplication).

The inmemory transport implementation is doing some fishy things right now. But "it works". It's actually covering up bugs in the subchannel implementation that are, I believe, holding circular references between internal/external subchannels and preventing proper shutdown from occurring. This is a pretty major issue, but it needs to be solved before the inmemory transport can be fixed. I will start working on that problem next, before dealing with the protobuf codegen for clients.

@dfawley dfawley added this to the grpc-next milestone Mar 4, 2026
@dfawley dfawley requested a review from arjan-bal March 4, 2026 01:16
@arjan-bal
Copy link
Copy Markdown
Collaborator

We can also delete the tonic codec used by the tonic transport: https://github.com/hyperium/tonic/blob/master/grpc/src/codec.rs

@dfawley
Copy link
Copy Markdown
Collaborator Author

dfawley commented Mar 4, 2026

We can also delete the tonic codec used by the tonic transport:

Done, thanks!

@dfawley dfawley force-pushed the generic_api3 branch 2 times, most recently from b7b8bfe to 4bd10dd Compare March 5, 2026 18:59
Comment thread grpc/src/client/transport/tonic/mod.rs Outdated
Comment thread grpc/src/lib.rs Outdated
Comment on lines +47 to +50
pub(crate) mod attributes;
pub(crate) mod byte_str;
pub(crate) mod rt;
pub(crate) mod send_future;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using pub(crate) in the root lib.rs file is essentially the same as making the module private. In both cases, only descendants of lib.rs can access it. I removed the pub(crate) modifiers in a previous PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Private mods are the same as pub(crate) mods? TIL. Changed.

Comment thread grpc/src/server/mod.rs Outdated
Comment thread grpc/src/rt/mod.rs Outdated
Comment thread grpc/src/client/subchannel.rs Outdated
Comment thread grpc/src/client/stream_util.rs Outdated
Comment thread grpc/src/client/service_config.rs
Comment thread grpc/src/client/service_config.rs Outdated
&& service_config
.load_balancing_policy
.as_ref()
.is_some_and(|p| *p == LbPolicyType::RoundRobin)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on whether we want to allow custom LBs, I can think of two better ways:

  1. Use the LbPolicyType enum as the key to the GLOBAL_LB_REGISTRY, or
  2. Have a function that maps LbPolicyType to an &'static str

The seems to be easier to extend when we add more LBs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was "implementing support for the loadBalancingPolicy field" with this:

https://github.com/grpc/grpc-proto/blob/dafe8c0aa9c80e28da7808ffade0f33638a16e3d/grpc/service_config/service_config.proto#L600

Apparently Java supports this being any string, so @nathanielford will update this later to work similarly.

But this is all here just so I can do RR in the example.

@arjan-bal arjan-bal assigned dfawley and unassigned arjan-bal Mar 6, 2026
Copy link
Copy Markdown
Collaborator Author

@dfawley dfawley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! PTAL

Comment thread grpc/src/client/transport/tonic/mod.rs Outdated
Comment thread grpc/src/lib.rs Outdated
Comment on lines +47 to +50
pub(crate) mod attributes;
pub(crate) mod byte_str;
pub(crate) mod rt;
pub(crate) mod send_future;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Private mods are the same as pub(crate) mods? TIL. Changed.

Comment thread grpc/src/server/mod.rs Outdated
Comment thread grpc/src/rt/mod.rs Outdated
@dfawley dfawley assigned arjan-bal and unassigned dfawley Mar 6, 2026
Copy link
Copy Markdown
Collaborator

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On major comment about making internal modules pub in lib.rs, otherwise LGTM.

Comment thread grpc/src/lib.rs Outdated
Comment on lines +47 to +50
pub mod attributes;
pub mod byte_str;
pub mod rt;
pub mod send_future;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should not be pub, simply mod.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed; thanks!

@arjan-bal arjan-bal assigned dfawley and unassigned arjan-bal Mar 9, 2026
@dfawley dfawley enabled auto-merge (squash) March 9, 2026 20:28
@dfawley dfawley disabled auto-merge March 9, 2026 20:29
@dfawley dfawley enabled auto-merge (squash) March 9, 2026 20:29
@dfawley dfawley merged commit e7809e7 into hyperium:master Mar 9, 2026
21 checks passed
@dfawley dfawley deleted the generic_api3 branch March 11, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants