Skip to content

impl(gax-internal): host resolution for custom universe domains#5464

Draft
alvarowolfx wants to merge 1 commit intogoogleapis:mainfrom
alvarowolfx:impl-gax-universe-domain-host
Draft

impl(gax-internal): host resolution for custom universe domains#5464
alvarowolfx wants to merge 1 commit intogoogleapis:mainfrom
alvarowolfx:impl-gax-universe-domain-host

Conversation

@alvarowolfx
Copy link
Copy Markdown
Contributor

Towards #3646

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 18, 2026

Codecov Report

❌ Patch coverage is 94.87179% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.73%. Comparing base (e1f7b3c) to head (9e13b1b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/gax-internal/src/host.rs 93.93% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5464      +/-   ##
==========================================
- Coverage   97.73%   97.73%   -0.01%     
==========================================
  Files         217      217              
  Lines       48186    48243      +57     
==========================================
+ Hits        47095    47149      +54     
- Misses       1091     1094       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@dbolduc dbolduc left a comment

Choose a reason for hiding this comment

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

universe_domain: &str,
) -> Result<(Uri, String), HostError> {
let default_origin = Uri::from_str(default_endpoint).map_err(HostError::Uri)?;
let service_endpoint = default_endpoint.replace(DEFAULT_UNIVERSE_DOMAIN, universe_domain);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should determine the service before doing this substitution.

(Can/should we provide the service to this function instea of the default_endpoint? I don't remember what the callers look like)

let universe_suffix = format!(".{universe_domain}");

let service = default_host
.strip_suffix(&universe_suffix)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

then we don't need this line.

default_host.strip_suffix(".googleapis.com"),
) else {

let default_suffix = format!(".{DEFAULT_UNIVERSE_DOMAIN}");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: this allocation is unnecessary. I'd rather spell out ".googleapis.com" than reuse the const and allocate an extra string when this is called.

// This is a global or regional endpoint. It should be used as the host.
// `{service}.{region}.rep.googleapis.com`
[s, _, "rep"] if *s == service => Ok((custom_origin, custom_host)),
[s] | [s, _, "rep"] if *s == service => Ok((custom_origin, custom_host)),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

comment: hmm, so this is needed now for the .with_endpoint("<service>.googleais.com").with_universe_domain("my-ud.com") case.

Otherwise we would fallback to the default host for the custom universe.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems too complicated. I think it is a result of substituting the universe domain in the default endpoint. Can we stop doing that?

We will also mess up theoretical1 cases like .with_endpoint("private.googleapis.com").with_universe_domain("my-ud.com"). I think it should use "<service>.googleapis.com" as the host, not "<service>.my-ud.com".

Footnotes

  1. While I don't think it is a real example, it seems more consistent to enforce this behavior.

Comment on lines -126 to -128
#[test_case("https://us-central1-wrong.gooogleapis.com", "test.googleapis.com"; "locational but with bad service")]
#[test_case("https://us-central1test.gooogleapis.com", "test.googleapis.com"; "maybe locational with missing dash")]
#[test_case("https://-test.gooogleapis.com", "test.googleapis.com"; "maybe locational with missing location")]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why remove these?

) else {

let default_suffix = format!(".{DEFAULT_UNIVERSE_DOMAIN}");
let universe_suffix = format!(".{universe_domain}");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: we could avoid this allocation if we pass in the universe suffix. Your call on if that hurts readability too much.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants