Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion spanner/src/apiv1/conn_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,23 @@ impl ConnectionManager {
domain: &str,
conn_options: &ConnectionOptions,
) -> Result<Self, Error> {
// Support Private Service Connect (PSC) endpoints for Spanner.
//
// When `domain` is a full HTTPS URL (e.g. "https://spanner-nonprod.p.googleapis.com")
// we use it as both the TLS SNI hostname and the gRPC connection target, mirroring
// the Java SDK's `SpannerOptions.setHost("https://...")` behaviour.
//
// When `domain` is a plain hostname (default: "spanner.googleapis.com") the existing
// behaviour is preserved: the public AUDIENCE constant is used as the target.
let (sni_domain, audience): (String, &str) = if domain.starts_with("https://") {
let host = domain.trim_start_matches("https://").trim_end_matches('/');
(host.to_string(), domain)
} else {
(domain.to_string(), AUDIENCE)
};

Ok(ConnectionManager {
inner: GRPCConnectionManager::new(pool_size, domain, AUDIENCE, environment, conn_options).await?,
inner: GRPCConnectionManager::new(pool_size, sni_domain, audience, environment, conn_options).await?,
})
}

Expand Down
Loading