credentials/google: make a non-blocking and context-aware call to fetch token. (#9184)
This PR is a follow-up to [PR #9118](https://github.com/grpc/grpc-go/pull/9118), refactoring the newly added GCP Service Account Identity call credentials to fetch tokens asynchronously and pass a 60 sec context timeout. Previously, if a valid token was not cached, GetRequestMetadata performed a blocking synchronous call to `creds.TokenProvider.Token(context.Background())`. This block occurred while holding the c.mu mutex lock, which blocked all other concurrent metadata retrievals. Additionally, the token fetch did not have a timeout and relies on the 15 sec timeout that metadata server works with. This PR refactors the credential to: * Run the token fetch in a background goroutine, releasing the mutex lock during the network call. * Deduplicate concurrent fetches using a channel broadcast pattern. * Allow waiting RPCs to unblock immediately if their context is canceled or expires. * Bound the background fetch itself with a defensive 60-second timeout. RELEASE NOTES: N/A --------- Co-authored-by: Easwar Swaminathan <easwars@google.com>
P
Pranjali-2501 committed
11d0baf8345f0867201e2d1e78292e68ac05bd30
Parent: 8d66cfc
Committed by GitHub <noreply@github.com>
on 6/24/2026, 8:07:47 AM