{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php/issues/590","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php/issues/590/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php/issues/590/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php/issues/590/events","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-php/issues/590","id":243081482,"number":590,"title":"Add an example on how to setup timeouts","user":{"login":"RyanGordon","id":535118,"avatar_url":"https://avatars6.githubusercontent.com/u/535118?v=4","gravatar_id":"","url":"https://api.github.com/users/RyanGordon","html_url":"https://github.com/RyanGordon","followers_url":"https://api.github.com/users/RyanGordon/followers","following_url":"https://api.github.com/users/RyanGordon/following{/other_user}","gists_url":"https://api.github.com/users/RyanGordon/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanGordon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanGordon/subscriptions","organizations_url":"https://api.github.com/users/RyanGordon/orgs","repos_url":"https://api.github.com/users/RyanGordon/repos","events_url":"https://api.github.com/users/RyanGordon/events{/privacy}","received_events_url":"https://api.github.com/users/RyanGordon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-07-14T18:53:32Z","updated_at":"2017-07-14T19:39:34Z","closed_at":null,"body":"I've been pouring over the code looking for how to properly set timeouts / retries in the recommended way for the Spanner Client.\r\n\r\nFor example let's trace through the [Spanner\\Database::execute(..)](https://github.com/GoogleCloudPlatform/google-cloud-php/blob/100569e036dabb01f6df1c3f42a69da9010f845c/src/Spanner/Database.php#L1219) function and how we could set timeouts for the request(s) it makes.\r\n\r\n[SpannerClient\\Database::execute(..)](https://github.com/GoogleCloudPlatform/google-cloud-php/blob/100569e036dabb01f6df1c3f42a69da9010f845c/src/Spanner/Database.php#L1219)  has an `$options` array as the 2nd parameter but doesn't mention any timeout settings.\r\n\r\nNext it calls [Spanner\\Operation::execute(..)](`https://github.com/GoogleCloudPlatform/google-cloud-php/blob/d15968cab653e039290f69a37048bede1a7eceba/src/Spanner/Operation.php#L164`) 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.\r\n\r\nThe options parameter is merged into the args parameter and the callback then calls: [Spanner\\Connection\\Grpc::executeStreamingSql(..)](https://github.com/GoogleCloudPlatform/google-cloud-php/blob/100569e036dabb01f6df1c3f42a69da9010f845c/src/Spanner/Connection/Grpc.php?utf8=%E2%9C%93#L451). 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(..)](https://github.com/GoogleCloudPlatform/google-cloud-php/blob/100569e036dabb01f6df1c3f42a69da9010f845c/src/Core/GrpcRequestWrapper.php?utf8=%E2%9C%93#L118) which takes 3 arguments but we don't pass in the third `$options` argument from the parent call which would have taken `requestTimeout, 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(..)](https://github.com/GoogleCloudPlatform/google-cloud-php/blob/100569e036dabb01f6df1c3f42a69da9010f845c/src/Spanner/V1/SpannerClient.php#L776) and the args array parameter is unwound to individual parameters by `call_user_func_array`\r\n\r\nSo presumably, assuming the number of arguments is always equal to 3, the last parameter will be `optionalArgs` at [Spanner\\v1\\SpannerClient::executeStreamingSql(..)](https://github.com/GoogleCloudPlatform/google-cloud-php/blob/100569e036dabb01f6df1c3f42a69da9010f845c/src/Spanner/V1/SpannerClient.php#L776) which is documented as explicitly taking `timeoutMillis` in the `optionalArgs` parameter but no mention of the other retrySettings, and timeoutMs parameters that could have been passed in from the previous function call.\r\n\r\nSo 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 :)"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php/issues/comments/315449271","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-php/issues/590#issuecomment-315449271","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php/issues/590","id":315449271,"user":{"login":"dwsupplee","id":2079879,"avatar_url":"https://avatars6.githubusercontent.com/u/2079879?v=4","gravatar_id":"","url":"https://api.github.com/users/dwsupplee","html_url":"https://github.com/dwsupplee","followers_url":"https://api.github.com/users/dwsupplee/followers","following_url":"https://api.github.com/users/dwsupplee/following{/other_user}","gists_url":"https://api.github.com/users/dwsupplee/gists{/gist_id}","starred_url":"https://api.github.com/users/dwsupplee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwsupplee/subscriptions","organizations_url":"https://api.github.com/users/dwsupplee/orgs","repos_url":"https://api.github.com/users/dwsupplee/repos","events_url":"https://api.github.com/users/dwsupplee/events{/privacy}","received_events_url":"https://api.github.com/users/dwsupplee/received_events","type":"User","site_admin":false},"created_at":"2017-07-14T19:39:34Z","updated_at":"2017-07-14T19:39:34Z","body":"@RyanGordon, thanks for creating this issue 👍. It's the kick in the butt we needed. We'll get this taken care of very soon :)."}}
{"actor":{"display_login":"dwsupplee"}}