Skip to content

feat(spanner): support Private Service Connect (PSC) endpoint override#443

Merged
yoshidan merged 1 commit into
yoshidan:mainfrom
yi-jun-mail:feature/psc-private-service-connect-endpoint
Jun 23, 2026
Merged

feat(spanner): support Private Service Connect (PSC) endpoint override#443
yoshidan merged 1 commit into
yoshidan:mainfrom
yi-jun-mail:feature/psc-private-service-connect-endpoint

Conversation

@yi-jun-mail

Copy link
Copy Markdown
Contributor

Summary

When ClientConfig.endpoint is 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 public AUDIENCE (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 with https://, 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:

  • Plain hostname (default spanner.googleapis.com): behaviour unchanged, AUDIENCE used as gRPC target
  • https:// URL: hostname used for TLS SNI, full URL used as gRPC dial target

Reference

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).

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.
@yoshidan yoshidan added the safe to test safe to test label Jun 23, 2026
@yoshidan yoshidan merged commit 32af9a1 into yoshidan:main Jun 23, 2026
9 checks passed
@yoshidan

Copy link
Copy Markdown
Owner

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test safe to test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants