Add an example on how to setup timeouts #590
Labels
documentation
priority: p1
Important issue which blocks shipping the next release. Will be fixed prior to next release.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
I've been poring over the code looking for how to properly set timeouts / retries in the recommended way for the Spanner Client.
For example let's trace through the Spanner\Database::execute(..) function and how we could set timeouts for the request(s) it makes.
SpannerClient\Database::execute(..) has an
$options
array as the 2nd parameter but doesn't mention any timeout settings.Next it calls Spanner\Operation::execute(..) which takes in the same
$options
array as 2nd parameter. Then it creates a callback which gets executed later but we'll skip to trace.The options parameter is merged into the args parameter and the callback then calls: Spanner\Connection\Grpc::executeStreamingSql(..). This function then passes a callable
[$this->spannerClient, 'executeStreamingSql']
and an array holding[session, sql, and the rest of the args]
as the two parameters to Core\GrpcRequestWrapper::send(..) which takes 3 arguments but we don't pass in the third$options
argument from the parent call which would have takenrequestTimeout, retries, and grpcOptions
. Now at this point the default retries/requestTimeout get merged into the grpcOptions defaults and then grpcOptions get merged into the last parameter of the$args
parameter. This is then sent through to Spanner\v1\SpannerClient::executeStreamingSql(..) and the args array parameter is unwound to individual parameters bycall_user_func_array
So presumably, assuming the number of arguments is always equal to 3, the last parameter will be
optionalArgs
at Spanner\v1\SpannerClient::executeStreamingSql(..) which is documented as explicitly takingtimeoutMillis
in theoptionalArgs
parameter but no mention of the other retrySettings, and timeoutMs parameters that could have been passed in from the previous function call.So all in all it's somewhat confusing to understand where we should be setting these different timeout / retry parameters and what the recommended way would be. Just a couple of simple high level examples would be enough. I'd be happy to add some documentation if someone can clarify in this ticket :)
The text was updated successfully, but these errors were encountered: