feat(spanner): support MultiEndpoint #9565
Merged
+2,180
−61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds optional gRPC-GCP channel pool (which is available in Cloud Spanner Java client) with its new MultiEndpoint feature.
The MultiEndpoint accepts a grouped lists of endpoints and creates a gRPC-GCP channel pool for each unique endpoint. The purposes of MultiEndpoint are:
endpoint is completely unavailable.
Here is an example of creating a client with MultiEndpoint
Endpoints reconfiguration
Then, with the above example, to route the calls to a different endpoint we can:
And all the following calls in the
client
will go to the west2 endpoint instead of east4.Using several MultiEndpoints
We can configure several MultiEndpoints, for example:
Then we can route a call to a specific MultiEndpoint ("default" is used by default) using context:
The call above will use an endpoint from the "west" MultiEndpoint group.
Fallback
If we add more than one endpoint to a MultiEndpoint, like in the example below:
Each MultiEndpoint will use the first endpoint in the list as long as any connection to that endpoint is alive.
When all connections to the first endpoint are broken, the MultiEndpoint will wait for
recoveryTimeout
and if the connections are still down, fail over to the next endpoint and so forth.When a connection to one of the previous endpoints in the list is recovered, the MultiEndpoint will switch back to that endpoint after
switchingDelay
.