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

[WIP] core: Allow LoadBalancer2 to use a different authority per SubChannel #2662

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion core/src/main/java/io/grpc/LoadBalancer2.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,17 @@ public abstract static class Helper {
* <p>The LoadBalancer is responsible for closing unused Subchannels, and closing all
* Subchannels within {@link #shutdown}.
*/
public abstract Subchannel createSubchannel(EquivalentAddressGroup addrs, Attributes attrs);
public abstract Subchannel createSubchannel(EquivalentAddressGroup addrs, Attributes attrs,
String authority);

/**
* Creates a Subchannel with the default authority of the load balancer.
*
* @see LoadBalancer2.Helper#createSubchannel(EquivalentAddressGroup, Attributes, String).
*/
public Subchannel createSubchannel(EquivalentAddressGroup addrs, Attributes attrs) {
return createSubchannel(addrs, attrs, getAuthority());
}

/**
* Out-of-band channel for LoadBalancer’s own RPC needs, e.g., talking to an external
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/java/io/grpc/internal/ManagedChannelImpl2.java
Original file line number Diff line number Diff line change
Expand Up @@ -600,16 +600,18 @@ private class LbHelperImpl extends LoadBalancer2.Helper {
}

@Override
public SubchannelImpl createSubchannel(EquivalentAddressGroup addressGroup, Attributes attrs) {
public SubchannelImpl createSubchannel(EquivalentAddressGroup addressGroup, Attributes attrs,
String authority) {
checkNotNull(addressGroup, "addressGroup");
checkNotNull(attrs, "attrs");
checkNotNull(authority, "authority");
ScheduledExecutorService scheduledExecutorCopy = scheduledExecutor;
checkState(scheduledExecutorCopy != null,
"scheduledExecutor is already cleared. Looks like you are calling this method after "
+ "you've already shut down");
final SubchannelImplImpl subchannel = new SubchannelImplImpl(attrs);
final InternalSubchannel internalSubchannel = new InternalSubchannel(
addressGroup, authority(), userAgent, backoffPolicyProvider, transportFactory,
addressGroup, authority, userAgent, backoffPolicyProvider, transportFactory,
scheduledExecutorCopy, stopwatchSupplier, channelExecutor,
new InternalSubchannel.Callback() {
// All callbacks are run in channelExecutor
Expand Down