Skip to content

chore(gax): support request attempt interception via options extensions#6014

Draft
olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:gax-attempt-interceptor-as-extension
Draft

chore(gax): support request attempt interception via options extensions#6014
olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:gax-attempt-interceptor-as-extension

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Note: This is an alternative implementation of the same feature as #5966

Allow mutating request headers on every RPC attempt (including retries) by checking for a closure extension inside RequestOptions.

If an Arc<dyn Fn(&mut HeaderMap, u32) + Send + Sync> is present in the request options extensions, it is executed before each request attempt with the 1-based attempt number. This enables downstream clients to inject and attempt-specific request headers without modifying the public API of google-cloud-gax[-internal] or introducing new public traits.

@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 an attempt interceptor mechanism for gRPC requests, allowing custom headers to be injected or modified per attempt, including retries. It also adds integration tests to verify the interceptor's behavior. The review feedback suggests extending this interceptor support to bidirectional streaming requests to ensure consistent behavior across all RPC types.

Comment thread src/gax-internal/src/grpc.rs Outdated
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.72%. Comparing base (ac6f825) to head (5de816e).

Files with missing lines Patch % Lines
src/gax-internal/src/grpc.rs 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6014      +/-   ##
==========================================
- Coverage   97.73%   97.72%   -0.01%     
==========================================
  Files         244      244              
  Lines       61161    61170       +9     
==========================================
+ Hits        59776    59781       +5     
- Misses       1385     1389       +4     

☔ View full report in Codecov by Harness.
📢 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.

@olavloite olavloite force-pushed the gax-attempt-interceptor-as-extension branch from 15b0941 to bcec26d Compare July 9, 2026 08:12
Allow mutating request headers on every RPC attempt (including retries)
by checking for a closure extension inside `RequestOptions`.

If an `Arc<dyn Fn(&mut HeaderMap, u32) + Send + Sync>` is present in the
request options extensions, it is executed before each request attempt
with the 1-based attempt number. This enables downstream clients to inject
and attempt-specific request headers without modifying the public API of
`google-cloud-gax[-internal]` or introducing new public traits.
@olavloite olavloite force-pushed the gax-attempt-interceptor-as-extension branch from bcec26d to 5de816e Compare July 9, 2026 08:18
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.

1 participant