-
Notifications
You must be signed in to change notification settings - Fork 4k
enable child channel plugins #12578
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
base: master
Are you sure you want to change the base?
enable child channel plugins #12578
Changes from 18 commits
476e5a8
2554a04
cf4909e
4905f72
36c2927
3259d67
eab10a9
d8398f5
374cbdf
367640e
0346e90
3e38536
d3eed7f
b9d687d
f816bba
bdcb745
4cfc0c6
4ff8d40
b8bd9f1
bfa5a26
03e55fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Copyright 2026 The gRPC Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.grpc; | ||
|
|
||
|
|
||
|
|
||
| /** | ||
| * A configurator for child channels created by gRPC's internal infrastructure. | ||
| * | ||
| * <p>This interface allows users to inject configuration (such as credentials, interceptors, | ||
| * or flow control settings) into channels created automatically by gRPC for control plane | ||
| * operations. Common use cases include: | ||
| * <ul> | ||
| * <li>xDS control plane connections</li> | ||
| * <li>Load Balancing helper channels (OOB channels)</li> | ||
| * </ul> | ||
| * | ||
| * <p><strong>Usage Example:</strong> | ||
| * <pre>{@code | ||
| * // 1. Define the configurator | ||
| * ChannelConfigurator configurator = builder -> { | ||
| * builder.maxInboundMessageSize(4 * 1024 * 1024); | ||
| * }; | ||
| * | ||
| * // 2. Apply to parent channel - automatically used for ALL child channels | ||
| * ManagedChannel channel = ManagedChannelBuilder | ||
| * .forTarget("xds:///my-service") | ||
| * .childChannelConfigurator(configurator) | ||
| * .build(); | ||
| * }</pre> | ||
| * | ||
| * <p>Implementations must be thread-safe as the configure methods may be invoked concurrently | ||
| * by multiple internal components. | ||
| * | ||
| * @since 1.81.0 | ||
| */ | ||
| @ExperimentalApi("https://github.com/grpc/grpc-java/issues/12574") | ||
| public interface ChannelConfigurator { | ||
|
|
||
| /** | ||
| * Configures a builder for a new child channel. | ||
| * | ||
| * <p>This method is invoked synchronously during the creation of the child channel, | ||
| * before {@link ManagedChannelBuilder#build()} is called. | ||
| * | ||
| * @param builder the mutable channel builder for the new child channel | ||
| */ | ||
| default void configureChannelBuilder(ManagedChannelBuilder<?> builder) {} | ||
|
AgraVator marked this conversation as resolved.
Outdated
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,8 +168,6 @@ protected T interceptWithTarget(InterceptorFactory factory) { | |
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| /** Internal-only. */ | ||
| @Internal | ||
|
AgraVator marked this conversation as resolved.
|
||
| protected interface InterceptorFactory { | ||
| ClientInterceptor newInterceptor(String target); | ||
| } | ||
|
|
@@ -638,8 +636,7 @@ public T disableServiceConfigLookUp() { | |
| * @return this | ||
| * @since 1.64.0 | ||
| */ | ||
| @Internal | ||
| protected T addMetricSink(MetricSink metricSink) { | ||
| public T addMetricSink(MetricSink metricSink) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's happening here? Why will this no longer be internal? Even if we were going to make it public, we wouldn't have it go immediately stable; it'd be experimental first.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When an application or test implements ChannelConfigurator, it receives a reference to the child channel's ManagedChannelBuilder.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the problem with that? What new thing do they need to do because of ChannelConfigurator? If
|
||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
|
|
@@ -661,6 +658,23 @@ public <X> T setNameResolverArg(NameResolver.Args.Key<X> key, X value) { | |
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Sets a configurator that will be applied to all internal child channels created by this | ||
| * channel. | ||
| * | ||
| * <p>This allows injecting configuration (like credentials, interceptors, or flow control) | ||
| * into auxiliary channels created by gRPC infrastructure, such as xDS control plane connections. | ||
| * | ||
| * @param channelConfigurator the configurator to apply. | ||
| * @return this | ||
| * @since 1.81.0 | ||
| */ | ||
| @ExperimentalApi("https://github.com/grpc/grpc-java/issues/12574") | ||
| public T childChannelConfigurator(ChannelConfigurator channelConfigurator) { | ||
| throw new UnsupportedOperationException("Not implemented"); | ||
| } | ||
|
|
||
| /** | ||
| * Builds a channel using the given parameters. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * Copyright 2026 The gRPC Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.grpc; | ||
|
|
||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.verifyNoInteractions; | ||
|
|
||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import org.junit.runners.JUnit4; | ||
|
|
||
| @RunWith(JUnit4.class) | ||
| public class ChannelConfiguratorTest { | ||
|
|
||
| @Test | ||
| public void defaultMethods_doNothing() { | ||
| ChannelConfigurator configurator = new ChannelConfigurator() {}; | ||
|
|
||
| ManagedChannelBuilder<?> mockChannelBuilder = mock(ManagedChannelBuilder.class); | ||
| configurator.configureChannelBuilder(mockChannelBuilder); | ||
| verifyNoInteractions(mockChannelBuilder); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.