Skip to content

feat(spanner): add client-level CallContextConfigurator to SpannerOptions - #14256

Merged
rahul2393 merged 4 commits into
mainfrom
spanner-client-call-context-config
Sep 4, 2026
Merged

feat(spanner): add client-level CallContextConfigurator to SpannerOptions#14256
rahul2393 merged 4 commits into
mainfrom
spanner-client-call-context-config

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Adds support for configuring a client-wide CallContextConfigurator via SpannerOptions.Builder#setCallContextConfigurator.

This allows applications (such as async and reactive pipelines where operations span across multiple executor threads) to customize gRPC options, timeouts, and headers across all RPCs without relying on thread-local io.grpc.Context propagation.

Key changes:

  • SpannerOptions: Added setCallContextConfigurator/getCallContextConfigurator. SpannerCallContextTimeoutConfigurator now derives from the supplied context rather than creating a blank default context.
  • GapicSpannerRpc:
    • Evaluates client-level configurator first, followed by thread-local configurator (allowing per-call overrides).
    • Reliably detects derived vs standalone delta contexts using an internal CallOptions.Key marker, preventing extra header duplication while preserving custom CallOptions and internal Spanner routing state.
    • Wraps configurator execution exceptions in SpannerException.
    • Fixed streaming reads in GapicSpannerRpc to pass getStreamingReadMethod() instead of getReadMethod().

…ions

Adds support for configuring a client-wide CallContextConfigurator via
SpannerOptions.Builder#setCallContextConfigurator.

This allows applications (such as async and reactive pipelines where
operations span across multiple executor threads) to customize gRPC
options, timeouts, and headers across all RPCs without relying on
thread-local io.grpc.Context propagation.

Key changes:
- SpannerOptions: Added setCallContextConfigurator/getCallContextConfigurator.
  SpannerCallContextTimeoutConfigurator now derives from the supplied
  context rather than creating a blank default context.
- GapicSpannerRpc:
  - Evaluates client-level configurator first, followed by thread-local
    configurator (allowing per-call overrides).
  - Reliably detects derived vs standalone delta contexts using an internal
    CallOptions.Key marker, preventing extra header duplication while
    preserving custom CallOptions and internal Spanner routing state.
  - Wraps configurator execution exceptions in SpannerException.
  - Fixed streaming reads in GapicSpannerRpc to pass getStreamingReadMethod()
    instead of getReadMethod().
@olavloite
olavloite requested review from a team as code owners September 3, 2026 16:49

@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 support for configuring a client-level CallContextConfigurator in SpannerOptions, allowing users to apply custom gRPC options, timeouts, or credentials client-wide without relying solely on thread-local context propagation. The changes sequentially evaluate client-level and thread-level configurators, merging their options appropriately, and include comprehensive unit tests to verify these behaviors. Feedback on the implementation points out a critical issue where call credentials from a CallCredentialsProvider could be silently wiped out during a merge if a custom configurator returns a standalone delta context with custom CallOptions. A code suggestion is provided to preserve the base credentials in this scenario.

@olavloite

Copy link
Copy Markdown
Contributor Author

/gemini review

@olavloite
olavloite requested a review from rahul2393 September 3, 2026 16:58

@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 support for configuring a client-level CallContextConfigurator in SpannerOptions, allowing users to apply custom gRPC options, timeouts, or credentials client-wide across all RPCs. It updates GapicSpannerRpc to sequentially evaluate both client-level and thread-local configurators, ensuring proper merging of contexts, options, and headers. Additionally, comprehensive unit tests have been added to verify these behaviors. As there are no review comments provided, I have no feedback to evaluate.

@rahul2393
rahul2393 merged commit eef74d2 into main Sep 4, 2026
206 checks passed
@rahul2393
rahul2393 deleted the spanner-client-call-context-config branch September 4, 2026 07:42
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.

2 participants