chore(gax-internal): add AttemptInterceptor#5966
Conversation
Introduces an internal `AttemptInterceptor` trait in `google-cloud-gax` that allows modifying outgoing RPC headers (`http::HeaderMap`) on every attempt. This is integrated into the `gax-internal` gRPC client and invoked on each unary and streaming attempt, passing the 1-based attempt number. This hook is required by the Cloud Spanner client to inject the `x-goog-spanner-request-id` header with incrementing attempt numbers on retries and stream resumes. The module is named `attempt_interceptor_internal` and hidden from the public documentation using the `_internal-semver` feature flag.
There was a problem hiding this comment.
Code Review
This pull request introduces the AttemptInterceptor trait and integrates it into the gRPC client, allowing users to intercept and modify headers on each RPC attempt. It also adds corresponding unit and integration tests. The review feedback highlights a critical compilation issue where AttemptInterceptor must be explicitly implemented for Arc<dyn AttemptInterceptor> to allow proper resolution of Option<T>. Additionally, there are minor style guide violations in the test files where .unwrap() is used instead of .expect().
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5966 +/- ##
==========================================
- Coverage 97.73% 97.72% -0.01%
==========================================
Files 244 245 +1
Lines 61161 61182 +21
==========================================
+ Hits 59776 59792 +16
- Misses 1385 1390 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
70de7cd to
b65e56d
Compare
To avoid spam like: #5966 (comment)
Moves AttemptInterceptor to gax-internal and remove the configuration option from ClientConfig in favor of a mutator on the internal gRPC client.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the AttemptInterceptor trait and integrates it into the gRPC client to allow intercepting and modifying outgoing RPC attempt headers, along with adding comprehensive integration tests. The review feedback suggests minor improvements: using the imported Arc type directly instead of its fully qualified path, dereferencing Arc with **self to avoid method resolution ambiguity, and replacing .unwrap() with .expect() in tests to align with the repository's style guide.
70375f2 to
f5446cd
Compare
|
/gemini-review |
Introduces an internal
AttemptInterceptortrait ingoogle-cloud-gaxthat allows modifying outgoing RPC headers (http::HeaderMap) on every attempt.This is integrated into the
gax-internalgRPC client and invoked on each unary and streaming attempt, passing the 1-based attempt number.This hook is required by the Cloud Spanner client to inject the
x-goog-spanner-request-idheader with incrementing attempt numbers on retries and stream resumes.The module is named
attempt_interceptor_internaland hidden from the public documentation using the_internal-semverfeature flag.