Repository navigation
fix(datastore): apply the timeout option to every RPC - #36732
ninjapanzer wants to merge 1 commit into
Conversation
The timeout given to Google::Cloud::Datastore.new was set only on the client-wide config. The generated client applies each RPC's own default (60 s) first, and Gapic::CallOptions#apply_defaults only fills an empty value, so the option had no effect. Copy the timeout to each RPC config as well, as google-cloud-pubsub does since googleapis#14405.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
1AbdullahButt
left a comment
There was a problem hiding this comment.
Correct.
Service#service used to set only config.timeout. Each RPC in the generated V1::Datastore::Client config carries its own 60 s default, and that per-RPC value is applied first, so the top-level value never reached a request. The new override_client_config_timeouts writes the timeout into every config.rpcs.* entry as well. It is the same code as override_client_config_timeouts in google-cloud-pubsub/lib/google/cloud/pubsub/service.rb, so the two libraries now behave the same way.
What I checked:
V1::Datastore::Client.newinservice.rbis the only place the datastore gem builds a client, so there is no second path that still drops the timeout.- With no
timeout, the helper is not called, so the per-RPC defaults stay as they were. - The new test also checks that the class-level
Client.configurekeeps its defaults. That matters because the block changes the per-instance config only.
I ran test/google/cloud/datastore/service_test.rb in a ruby:3.3 container (with -rminitest/mock, as the description says): 4 runs, 0 failures. With service.rb reverted to main, 2 of the 4 fail: the per-RPC config test and the "sends requests with the configured timeout" test. So the test catches the bug.
Reviewed with help from Claude Code.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
bundle exec rake ciin the gem subdirectory.The
timeoutoption ofGoogle::Cloud::Datastore.newwas set only on the client-wide config. The generated client applies each RPC's own 60 s default first, andGapic::CallOptions#apply_defaultsonly fills an empty value, so the option never reached a request.This copies the timeout to each
config.rpcs.*.timeoutinService#service, the same way google-cloud-pubsub does since #14405. Nothing changes when no timeout is given.A new
test/google/cloud/datastore/service_test.rbchecks the per-RPC config with and without a timeout, and thatlookup,commitandallocate_idsare sent with the configured timeout.On the unticked CONTRIBUTING box: locally, with Ruby 3.4.8,
bundle exec rake testpasses only withminitest/mockpreloaded (282 runs, 0 failures, 0 errors); without it, existing tests fail withuninitialized constant Minitest::Mock, andrake doctestandrake rubocop(6 offenses inproperties.rb) also fail, all identically onmain. The changed file has no rubocop offenses.OVERVIEW.mdalready documents the option as now behaving, so no documentation change was needed.closes: #36632
Made with GitRanks Contribute and Claude Code (Fable) · Reviewed and submitted by @ninjapanzer
Something off? Tell us or opt out in one step — maintainers are always in control