Skip to content

feat(spanner): add with_num_channels setter to the client builder#6072

Open
fornwall wants to merge 2 commits into
googleapis:mainfrom
fornwall:up-7-channel-pool-builder-setter
Open

feat(spanner): add with_num_channels setter to the client builder#6072
fornwall wants to merge 2 commits into
googleapis:mainfrom
fornwall:up-7-channel-pool-builder-setter

Conversation

@fornwall

@fornwall fornwall commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

The gRPC channel-pool size was configurable only via the SPANNER_NUM_CHANNELS environment variable, read inside the client builder's build path.

The gRPC channel-pool size was configurable only via the
SPANNER_NUM_CHANNELS environment variable, read inside the client
builder's build path.

Replace the unit-struct Factory + gax generic ClientBuilder type alias
with a hand-rolled ClientBuilder (mirroring the sibling pubsub crate's
BasePublisherBuilder), storing the channel count as an
Option<usize>.

Add a with_num_channels setter; build() resolves the count with the
precedence explicit builder value > SPANNER_NUM_CHANNELS env var >
default of 4, so existing env-var and default behavior is preserved
when the setter is unused.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
@fornwall
fornwall requested review from a team as code owners July 16, 2026 13:26
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Jul 16, 2026

@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 refactors the Spanner client construction by replacing the existing factory pattern with a dedicated ClientBuilder struct. This change enables more flexible configuration, including setting the gRPC channel pool size, endpoint, credentials, and retry policies. The review identified a potential runtime panic due to a division-by-zero if the channel pool size is set to zero, and suggested implementing the Default trait for ClientBuilder to align with repository style guidelines.

Comment thread src/spanner/src/client.rs Outdated
Comment thread src/spanner/src/client.rs
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@olavloite olavloite added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jul 17, 2026
@olavloite

Copy link
Copy Markdown
Contributor

@fornwall We are considering further options for setting up the gRPC channel pool, and are therefore not ready to commit to a specific public API for this at the moment. I think that it would be better if you would open a feature request with the specific options / feature that you need for your use case.

@fornwall

Copy link
Copy Markdown
Contributor Author

We are considering further options for setting up the gRPC channel pool, and are therefore not ready to commit to a specific public API for this at the moment. I think that it would be better if you would open a feature request with the specific options / feature that you need for your use case.

@olavloite Thanks - created #6085. Should I close this PR (or feel free to close it yourself)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API. do not merge Indicates a pull request not ready for merge, due to either quality or timing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants