Skip to content

feat(gax): add client-level attempt_timeout and use as transport default - #5630

Merged
dbolduc merged 5 commits into
googleapis:mainfrom
abhinavgautam01:feat/add-client-attempt-timeout
May 11, 2026
Merged

dbolduc merged 5 commits into
googleapis:mainfrom
abhinavgautam01:feat/add-client-attempt-timeout

Conversation

@abhinavgautam01

Copy link
Copy Markdown
Contributor

Fixes #4466

Adds an optional client-level per-attempt timeout and applies it as a transport fallback when requests don't set their own per-attempt timeout.

What changed:

  • Add attempt_timeout: Option to internal ClientConfig and ClientBuilder::with_attempt_timeout(...)
  • gax-internal/http & grpc: store client default and merge into RequestOptions when absent

Behavior:

  • Per-request RequestOptions.attempt_timeout still takes precedence.

Tests:

  • Ran google-cloud-gax, google-cloud-gax-internal and full workspace tests locally — all pass.

@abhinavgautam01
abhinavgautam01 requested a review from a team as a code owner May 8, 2026 04:29

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces a client-level attempt_timeout configuration for gRPC and HTTP clients, allowing a default timeout to be set via the ClientBuilder. The implementation merges this default with per-request options, ensuring request-specific settings take precedence. Review feedback highlights opportunities to optimize the merging logic by avoiding unnecessary cloning of RequestOptions through the use of Option::or or std::borrow::Cow, and suggests refactoring duplicated logic into a helper function.

Comment thread src/gax-internal/src/grpc.rs Resolved
Comment thread src/gax-internal/src/grpc.rs Resolved
Comment thread src/gax-internal/src/http.rs Resolved
@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

ping @dbolduc

@dbolduc

dbolduc commented May 8, 2026

Copy link
Copy Markdown
Member

/gcbrun

@codecov

codecov Bot commented May 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.76%. Comparing base (02edf0b) to head (011064e).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5630   +/-   ##
=======================================
  Coverage   97.76%   97.76%           
=======================================
  Files         221      221           
  Lines       51115    51156   +41     
=======================================
+ Hits        49971    50013   +42     
+ Misses       1144     1143    -1     

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

@dbolduc dbolduc left a comment

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.

Looks good, thanks! We just need to get past the CI.

I think we need a

cargo fmt -p google-cloud-gax
cargo fmt -p google-cloud-gax-internal

And then because we added a new API to gax which gax-internal depends on, we need to bump the version of gax.

That happens in:

  • Cargo.toml
  • src/gax/Cargo.toml

Then we need to update the generated Cargo.lock with like: cargo check -p google-cloud-gax

Comment thread src/gax/src/client_builder.rs Resolved
Add attempt_timeout: Option<std::time::Duration> to internal ClientConfig and ClientBuilder::with_attempt_timeout.

gax-internal HTTP and gRPC transports use the client default when no per-request attempt timeout is set.
…ient attempt_timeout

Add resolve_effective_timeout helper and use it to merge
per-request and client-level attempt_timeouts without cloning RequestOptions.
Simplify HTTP and gRPC transport logic and remove redundant cloning.

Addresses code-review feedback.
@abhinavgautam01
abhinavgautam01 force-pushed the feat/add-client-attempt-timeout branch from 5dc017d to 5295697 Compare May 8, 2026 16:49
@abhinavgautam01
abhinavgautam01 requested a review from dbolduc May 8, 2026 17:09
@dbolduc

dbolduc commented May 8, 2026

Copy link
Copy Markdown
Member

/gcbrun

@coryan coryan left a comment

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.

@dbolduc I think we also need to make the version change in librarian.yaml or librarian bump will be confused.

Comment thread src/gax/Cargo.toml Resolved
Comment thread Cargo.toml Resolved
@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

ping @dbolduc

@dbolduc

dbolduc commented May 11, 2026

Copy link
Copy Markdown
Member

ping @dbolduc

@coryan is right. The version should be 1.11.0, and I forgot we need to update it in librarian.yaml as well.

version: 1.9.0

Can you fix that?

Minor version for breaking-API-leaning change; sync workspace,
Cargo.lock, and librarian.yaml.
@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

ping @dbolduc

@coryan is right. The version should be 1.11.0, and I forgot we need to update it in librarian.yaml as well.

version: 1.9.0

Can you fix that?

done..!

@abhinavgautam01
abhinavgautam01 requested a review from coryan May 11, 2026 15:59
@dbolduc

dbolduc commented May 11, 2026

Copy link
Copy Markdown
Member

/gcbrun

@dbolduc dbolduc left a comment

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.

LGTM, thanks! Let's see what the builds say.

@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

LGTM, thanks! Let's see what the builds say.

hopefully the builds stay green...🤧

@dbolduc
dbolduc merged commit 2ad561e into googleapis:main May 11, 2026
35 of 36 checks passed
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.

Set per attempt_timeout on the client

3 participants