Skip to content

Improve GrpcChannelFactory API #78

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

Merged
merged 2 commits into from
Jan 3, 2025

Conversation

onobc
Copy link
Contributor

@onobc onobc commented Dec 11, 2024

  • Introduce a ChannelBuilderOptions that holds customizer, shutdownGracePeriod, and interceptors.
  • Add type to GrpcChannelFactory and GrpcChannelBuilderCustomizer

@onobc onobc requested a review from dsyer December 11, 2024 05:18
@onobc onobc marked this pull request as draft December 11, 2024 05:18
Copy link
Contributor Author

@onobc onobc left a comment

Choose a reason for hiding this comment

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

@dsyer I believe this extended builder concept solves several of our current pain points.

Note

I bring the following point up now because it could impact the new extended channel builder design in this code proposal.

I noticed that the NettyChannelBuilder static methods handle the unix scheme, for example:

if (DOMAIN_SOCKET_ADDRESS_SCHEME.equals(address.getScheme())) {
    final String path = GrpcUtils.extractDomainSocketAddressPath(address.toString());
    return NettyChannelBuilder.forAddress(new DomainSocketAddress(path))
            .channelType(EpollDomainSocketChannel.class)
            .eventLoopGroup(new EpollEventLoopGroup());
} else {
    return NettyChannelBuilder.forTarget(address.toString())
            .defaultLoadBalancingPolicy(properties.getDefaultLoadBalancingPolicy());
}
  1. Does the Grpc.newChannelBuilder() we are currently leveraging support unix scheme for Netty?
  2. Refresh my memory why we did not have the createChannel return the specific ManagedChannelBuilder (e.g. NettyChannelBuilder)? Was it for simplicity?

@onobc onobc changed the title Introduce extended builder WIP: Introduce extended builder Dec 11, 2024
@dsyer
Copy link
Member

dsyer commented Dec 11, 2024

  1. Does the Grpc.newChannelBuilder() we are currently leveraging support unix scheme for Netty?

At the time I wrote it I believed not (copied code from ecosystem), but looking at the UdsNameResolverProvider I'd say it probably does. Maybe there are some constraints related to customizing e-poll?

  1. Refresh my memory why we did not have the createChannel return the specific ManagedChannelBuilder (e.g. NettyChannelBuilder)? Was it for simplicity?

I didn't want the user to have to know what kind of channel it is (same for servers). Mainly because I anticipated substituting the in-process version in tests. Maybe that was a bad decision - we'd have to support the in-process transport in a different way if we change the contract.

@onobc onobc force-pushed the channel-factory-contract branch 4 times, most recently from 473a742 to cc7c249 Compare December 30, 2024 04:07

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
This commit improves the GrpcChannelFactory createChannel API by
introducing `ChannelBuilderOptions` that can be specified during
channel creation.

Additionally, concrete Netty channel factory implementations have
been added as well as adding type to the GrpcChannelBuilderCustomizer
which helps match customizers to channel factories.
@onobc onobc force-pushed the channel-factory-contract branch from 946c013 to 0771303 Compare January 2, 2025 23:23
@onobc onobc changed the title WIP: Introduce extended builder Improve GrpcChannelFactory API Jan 2, 2025
@onobc onobc marked this pull request as ready for review January 2, 2025 23:24
@onobc onobc requested a review from dsyer January 2, 2025 23:24
@dsyer
Copy link
Member

dsyer commented Jan 3, 2025

LGTM. Maybe we should use the overloaded default factory method in the tests where possible though (no need for the second argument if it’s just the default)?

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@dsyer dsyer merged commit 81990f0 into spring-projects:main Jan 3, 2025
1 check passed
@onobc onobc deleted the channel-factory-contract branch January 4, 2025 00:11
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.

None yet

2 participants