feat(spanner): support Private Service Connect (PSC) endpoint override#443
Merged
yoshidan merged 1 commit intoJun 23, 2026
Conversation
When ClientConfig.endpoint is set to a full HTTPS URL such as https://spanner-nonprod.p.googleapis.com (a GCP Private Service Connect endpoint), use it as both the TLS SNI hostname and the gRPC connection target URL. Previously, GRPCConnectionManager was always called with the hardcoded AUDIENCE constant (https://spanner.googleapis.com/) as the connection target, so configuring a custom endpoint only affected the TLS SNI name but not the actual dial target — PSC connections silently fell back to the public endpoint. This mirrors the behaviour of the Java SDK's SpannerOptions.setHost(): https://cloud.google.com/spanner/docs/private-service-connect Backwards-compatible: when endpoint is a plain hostname (the default), the existing AUDIENCE constant is used unchanged.
Owner
|
LGTM! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When
ClientConfig.endpointis set to a full HTTPS URL (e.g.https://spanner-nonprod.p.googleapis.com), the existing code only used it for TLS SNI but still dialled the hardcoded publicAUDIENCE(https://spanner.googleapis.com/) as the actual gRPC connection target. Private Service Connect (PSC) connections silently fell back to the public endpoint.This PR mirrors the Java SDK's
SpannerOptions.setHost("https://...")behaviour: when the configured endpoint starts withhttps://, extract the hostname for TLS SNI and use the full URL as the gRPC dial target.Change
spanner/src/apiv1/conn_pool.rs— 16 lines added, 1 line changed, fully backwards-compatible:spanner.googleapis.com): behaviour unchanged,AUDIENCEused as gRPC targethttps://URL: hostname used for TLS SNI, full URL used as gRPC dial targetReference
SpannerOptions.setHost()Testing
Battle-tested in production connecting from Azure AKS to non-prod Google Cloud Spanner via a Walmart PSC endpoint (
https://spanner-nonprod.p.googleapis.com).