in grpc-gcp/src/main/java/com/google/cloud/grpc/multiendpoint/MultiEndpoint.java [240:263]
private synchronized void updateCurrentEndpoint(Endpoint current, String newCurrentId) {
// If no current or became unavailable then switch immediately.
if (current == null || current.getState().equals(EndpointState.UNAVAILABLE)) {
registerSwitch(currentId, newCurrentId);
currentId = newCurrentId;
return;
}
if (!isSwitchingDelayed()) {
registerSwitch(currentId, newCurrentId);
currentId = newCurrentId;
return;
}
switchTo = newCurrentId;
if (switchTo.equals(currentId)) {
return;
}
if (scheduledSwitch == null || scheduledSwitch.isDone()) {
scheduledSwitch =
executor.schedule(this::switchCurrentEndpoint, switchingDelay.toMillis(), MILLISECONDS);
}
}