Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use the universe domain if it is provided by the user #1563

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

danieljbruce
Copy link
Contributor

@danieljbruce danieljbruce commented Jan 8, 2025

Summary:

The user should be able to set the universe domain so that outgoing calls work with a different Google Cloud Universe. Right now, if the user specifies a universe domain then it will not get used and the request will just be sent to the default Bigtable endpoint.

Changes:

src/index.ts: The change here is that when a custom url is not provided, but a universe domain is provided then the servicePath will use the universe domain provided. This is done for each Gapic client and ensures requests will be made to the universe domain instead of the default Bigtable service.

system-test/service-path.ts: Two tests are added to ensure the service path is always set correctly. For instance, when a custom endpoint is provided then the service path will still always be that custom endpoint. When a custom endpoint is NOT provided, but a universe domain is provided then the service path is set to use the universe domain instead of the default endpoint.

Alternatives:

  1. Instead of requiring the user to set the universe domain for each Gapic client, we could expose a universeDomain option that would apply to all clients. While this would make things easier for users, it is an API change so it is not reversible. For now we should not change the API since users already have a way to specify the universe domains for the Gapic clients. We can always add this option later.
  2. When a custom endpoint is not provided then in the handwritten layer we could not provide a service path. The Pros of this option is that we can rely on the code in the Gapic layer for building the service path instead of creating the getDomain function introducing duplicate code and this would reduce technical debt. The main problem with this option is that it means providedCustomServicePath will now be undefined and this value is used in the grpc stub so we don't know how such a change might affect the outgoing API calls. The code to implement this alternative also gets messy if Alternative 1 isn't adopted as well.

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigtable Issues related to the googleapis/nodejs-bigtable API. labels Jan 8, 2025
@danieljbruce danieljbruce marked this pull request as ready for review January 8, 2025 21:59
@danieljbruce danieljbruce requested review from a team as code owners January 8, 2025 21:59
servicePath: customEndpointBaseUrl || defaultAdminBaseUrl,
servicePath:
customEndpointBaseUrl ||
`bigtableadmin.${getDomain(options.BigtableTableAdminClient)}`,
Copy link
Contributor Author

@danieljbruce danieljbruce Jan 10, 2025

Choose a reason for hiding this comment

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

If no universe domain and custom endpoint is provided then this will still be bigtableadmin.googleapis.com.

servicePath: customEndpointBaseUrl || defaultBaseUrl,
servicePath:
customEndpointBaseUrl ||
`bigtable.${getDomain(options.BigtableClient)}`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If no universe domain and custom endpoint is provided then this will still be bigtable.googleapis.com.

Copy link

@daniel-sanche daniel-sanche left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, with a few small comments.

I'm not too familiar with the universe domains yet though, so you might also want to assign a reviewer who understands potential complications there

* @returns {string} The universe domain.
*/
function getDomain(opts?: gax.ClientOptions) {
// This code for universe domain was taken from the Gapic Layer.

Choose a reason for hiding this comment

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

can you add a permalink to where this came from?

servicePath: customEndpointBaseUrl || defaultBaseUrl,
servicePath:
customEndpointBaseUrl ||
`bigtable.${getDomain(options.BigtableClient)}`,
Copy link

@daniel-sanche daniel-sanche Jan 10, 2025

Choose a reason for hiding this comment

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

What would you think about adding pathPrefix as an argument to getDomain (and maybe renaming the method if needed), instead of manually building the string here? I think that would be a bit easier to read, and seems more natural to me since the returned string isn't useful on its own

@danieljbruce danieljbruce requested a review from bshaffer January 10, 2025 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the googleapis/nodejs-bigtable API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants