Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

feat(spanner): add TPC support#2333

Merged
alkatrivedi merged 1 commit intomainfrom
tpc-support
Jul 4, 2025
Merged

feat(spanner): add TPC support#2333
alkatrivedi merged 1 commit intomainfrom
tpc-support

Conversation

@alkatrivedi
Copy link
Copy Markdown
Contributor

@alkatrivedi alkatrivedi commented Jun 24, 2025

This PR contains the code changes for supporting TPC in node client.

@alkatrivedi alkatrivedi requested a review from a team June 24, 2025 09:18
@alkatrivedi alkatrivedi requested a review from a team as a code owner June 24, 2025 09:18
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: spanner Issues related to the googleapis/nodejs-spanner API. labels Jun 24, 2025
@alkatrivedi alkatrivedi marked this pull request as draft June 24, 2025 09:19
@alkatrivedi alkatrivedi force-pushed the tpc-support branch 2 times, most recently from 67df505 to ddd6e8f Compare June 27, 2025 08:48
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jun 27, 2025
@alkatrivedi alkatrivedi marked this pull request as ready for review June 27, 2025 09:46
@alkatrivedi alkatrivedi force-pushed the tpc-support branch 2 times, most recently from 5d67c5a to ab63f1b Compare June 27, 2025 09:58
rahul2393
rahul2393 previously approved these changes Jun 30, 2025
src/index.ts Outdated
[P in keyof T]: P extends U ? EnumKey<E> | null | undefined : T[P];
};

function getUniverseDomainOnly(options: SpannerOptions): string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename to getUniverseDomain

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

defaultTransactionOptions?: Pick<RunTransactionOptions, 'isolationLevel'>;
observabilityOptions?: ObservabilityOptions;
interceptors?: any[];
universe_domain?: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the documentation for it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/index.ts Outdated
options?.universeDomain &&
options?.universe_domain !== options?.universeDomain
) {
throw new Error(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not getting this , why do we have two different properties ?

Copy link
Copy Markdown
Contributor Author

@alkatrivedi alkatrivedi Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at gax level we are handling both the options, which is why we are handling two different properties here as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on our offline discussion, we will handling this error in separate PR, hence I have removed this piece of code from here

@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: l Pull request size is large. labels Jun 30, 2025
@alkatrivedi alkatrivedi force-pushed the tpc-support branch 4 times, most recently from ad1ce47 to 5cea51f Compare June 30, 2025 16:52
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jun 30, 2025
src/index.ts Outdated
*
* This function checks for a universe domain in the following order:
* 1. The `universeDomain` property within the provided spanner options.
* 2. The `GOOGLE_CLOUD_UNIVERSE_DOMAIN` environment variable.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this required? is it a standard across all the libraries?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make the implementation consistent with the gax library I am checkin domain via env as well

is it a standard across all the libraries?

otherwise no, if we see other database libraries, Bigtable is handling it(they have merged the PR as well), while BigQuery is not handling via env(they also have merged the PR)

@rahul2393 can you please confirm for Spanner Go client?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: we are not merging this PR, the setup and implementation is just for manual testing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that autogenerated clients are using the same env

src/index.ts Outdated
/**
* The Trusted Cloud Domain (TPC) DNS of the service used to make requests.
*/
universe_domain?: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we having two options.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are asking clients to configure it. There's no compelling reasons for us to have both unless it's defined as standard across all the libraries.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that autogenerated clients are also having two fields for same variable. Would you mind checking with gax or nodejs or TPC to understand the rational behind this decision?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure let me check with the team

src/index.ts Outdated
options.sslCreds = grpc.credentials.createInsecure();
}

const universeDomain = getDomain('spanner', options);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename this. universeDomain usually used for googleapis.com. but result is spanner url.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@product-auto-label product-auto-label bot added the size: xl Pull request size is extra large. label Jul 3, 2025
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Jul 3, 2025
src/index.ts Outdated
);
ensureInitialContextManagerSet();
this._nthClientId = nextSpannerClientId();
this._universeDomain = getUniverseDomain(options);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we calling getUniverseDomain again here, save it the first time .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@alkatrivedi alkatrivedi added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Jul 3, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 3, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 3, 2025
surbhigarg92
surbhigarg92 previously approved these changes Jul 3, 2025
surbhigarg92
surbhigarg92 previously approved these changes Jul 3, 2025
sakthivelmanii
sakthivelmanii previously approved these changes Jul 3, 2025
@alkatrivedi alkatrivedi added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Jul 3, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 3, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 3, 2025
@alkatrivedi alkatrivedi added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 3, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 3, 2025
@alkatrivedi alkatrivedi added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Jul 3, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 3, 2025
options.sslCreds = grpc.credentials.createInsecure();
}

const universeEndpoint = getUniverseDomain(options);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need an extra variable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were calling getUniverseDomain(options) at two points:

const spannerUniverseEndpoint = 'spanner.' + getUniverseDomain(options);
this._universeDomain = getUniverseDomain(options);

so now I am storing the value returned from the method getUniverseDomain in a single variable and using that variable on those two places

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change has been made with ref to this comment

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

Labels

api: spanner Issues related to the googleapis/nodejs-spanner API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants