@@ -97,7 +97,8 @@ protected function doRequest($service, $method, array $data = [])
9797 json_decode ($ request ->serializeToJsonString (), true )
9898 );
9999
100- $ call = $ this ->client ->$ method ($ request , $ this ->meta );
100+ $ options = $ this ->buildGrpcOptions ();
101+ $ call = $ this ->client ->$ method ($ request , $ this ->meta , $ options );
101102
102103 if (method_exists ($ call , 'wait ' )) {
103104 list ($ response , $ status ) = $ call ->wait ();
@@ -152,7 +153,8 @@ protected function doStreamRequest($service, $method, $data = [])
152153
153154 $ request = new $ requestClass ($ data );
154155
155- $ call = $ this ->client ->$ method ($ request , $ this ->meta );
156+ $ options = $ this ->buildGrpcOptions ();
157+ $ call = $ this ->client ->$ method ($ request , $ this ->meta , $ options );
156158
157159 if (method_exists ($ call , 'responses ' )) {
158160 // $status = $call->getStatus();
@@ -238,7 +240,7 @@ protected function processResponse($service, $method, $response, $resultClass)
238240 $ this ->logger ()->debug ('YDB: Received API response [ ' . $ resultClass . ']. ' , json_decode ($ jsonResult , true ));
239241
240242 $ result = new $ resultClass ;
241- $ result ->mergeFromJsonString ($ jsonResult, true );
243+ $ result ->mergeFromJsonString ($ jsonResult );
242244 }
243245 }
244246
@@ -323,6 +325,23 @@ protected function checkDiscovery(){
323325 }
324326 }
325327
328+ /**
329+ * Build gRPC call options including timeout if configured
330+ *
331+ * @return array
332+ */
333+ protected function buildGrpcOptions ()
334+ {
335+ $ options = [];
336+
337+ $ timeout = $ this ->ydb ->getGrpcTimeout ();
338+ if ($ timeout !== null ) {
339+ $ options ['timeout ' ] = $ timeout ;
340+ }
341+
342+ return $ options ;
343+ }
344+
326345 public static $ ydbExceptions = [
327346 StatusCode::STATUS_CODE_UNSPECIFIED => \YdbPlatform \Ydb \Exceptions \Ydb \StatusCodeUnspecified::class,
328347 StatusCode::BAD_REQUEST => \YdbPlatform \Ydb \Exceptions \Ydb \BadRequestException::class,
0 commit comments