chore(gax): add AttemptInterceptor to ClientConfig#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✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5966 +/- ##
========================================
Coverage 97.71% 97.71%
========================================
Files 242 243 +1
Lines 60976 61078 +102
========================================
+ Hits 59582 59683 +101
- Misses 1394 1395 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
70de7cd to
b65e56d
Compare
To avoid spam like: #5966 (comment)
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.