Skip to content

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

Open
abhinavgautam01 wants to merge 4 commits intogoogleapis:mainfrom
abhinavgautam01:feat/add-client-attempt-timeout
Open

feat(gax): add client-level attempt_timeout and use as transport default#5630
abhinavgautam01 wants to merge 4 commits intogoogleapis:mainfrom
abhinavgautam01:feat/add-client-attempt-timeout

Conversation

@abhinavgautam01
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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

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 Outdated
Comment thread src/gax-internal/src/grpc.rs Outdated
Comment thread src/gax-internal/src/http.rs Outdated
@abhinavgautam01
Copy link
Copy Markdown
Author

ping @dbolduc

@dbolduc
Copy link
Copy Markdown
Member

dbolduc commented May 8, 2026

/gcbrun

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.76%. Comparing base (02edf0b) to head (5295697).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5630   +/-   ##
=======================================
  Coverage   97.76%   97.76%           
=======================================
  Files         221      221           
  Lines       51115    51156   +41     
=======================================
+ Hits        49971    50014   +43     
+ Misses       1144     1142    -2     

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

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
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
Copy link
Copy Markdown
Member

dbolduc commented May 8, 2026

/gcbrun

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

2 participants