-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
There is an ExitIdler
interface that was added four years ago, which includes the ExitIdle
method:
Lines 365 to 377 in 6995ef2
// ExitIdler is an optional interface for balancers to implement. If | |
// implemented, ExitIdle will be called when ClientConn.Connect is called, if | |
// the ClientConn is idle. If unimplemented, ClientConn.Connect will cause | |
// all SubConns to connect. | |
// | |
// Notice: it will be required for all balancers to implement this in a future | |
// release. | |
type ExitIdler interface { | |
// ExitIdle instructs the LB policy to reconnect to backends / exit the | |
// IDLE state, if appropriate and possible. Note that SubConns that enter | |
// the IDLE state will not reconnect until SubConn.Connect is called. | |
ExitIdle() | |
} |
This is an optional interface that LB (load balancer) policies can implement. The ExitIdle
method is called by the channel to transition the LB policy out of Idle
mode when the channel is connected but no RPC has been made (i.e., the picker hasn't been called). If a top-level LB policy doesn't implement ExitIdler
, the gracefulswitch
balancer invokes Connect
on all subchannels created by the LB policy.
As noted in the interface's godoc, “it will be required for all balancers to implement this in a future release.” Recently, we discovered potential bugs that can occur when a tree of LB policies is used and the parent LB implements ExitIdler
but a child LB does not. To address this, we’ve decided to move ExitIdle
into the Balancer
interface directly.
This is a breaking change. However, since the balancer
package is marked experimental
and it has been four years since ExitIdler
was introduced, we believe this change is acceptable.
We will fix some known projects that implement their own LB policies and wait for their releases before making the change in gRPC.
- GCP client libraries: PR merged, new version released.
- etcd: They've removed their custom balancer in clientv3: Replace balancer with upstream grpc solution etcd-io/etcd#12671