feat(spanner): add with_num_channels setter to the client builder#6072
feat(spanner): add with_num_channels setter to the client builder#6072fornwall wants to merge 2 commits into
Conversation
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>
There was a problem hiding this comment.
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.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
@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. |
@olavloite Thanks - created #6085. Should I close this PR (or feel free to close it yourself)? |
The gRPC channel-pool size was configurable only via the
SPANNER_NUM_CHANNELSenvironment variable, read inside the client builder's build path.