-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
grpclb: support "pick_first" child policy #5438
Conversation
This is needed for GRPCLB pick_first support, which needs to attach tokens to headers, and the tokens are per server. In pick_first, all addresses are in a single Subchannel, thus the LoadBalancer needs to know which backend is used for a new stream. With this new transport attribute, the LoadBalancer can use one EAG per backend, put the token in the EAG attributes, and then access the token via the transport attribute available from ClientStreamTracer.StreamInfo.
PickResult picked(Metadata headers); | ||
} | ||
|
||
@VisibleForTesting | ||
static final class BackendEntry implements RoundRobinEntry { | ||
final Subchannel subchannel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being stored now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's always non-null in BackendEntry
, and there are quite a few places that need to retrieve the subchannel from BackendEntry
. entry.subchannel
is easier to reason than entry.result.getSubchannel()
that you won't get a null
.
The PICK_FIRST mode puts all backend addresses in a single Subchannel. There are a few points where it's different from the default ROUND_ROBIN mode:
TokenAttachingTracerFactory
) than ROUND_ROBINGrpclbState
and starts a new one with the new mode. All connections will be closed during the transition. We don't expect this to happen in practice given the specific use case of PICK_FIRST.