Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/Traits/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ protected function doRequest($service, $method, array $data = [])
json_decode($request->serializeToJsonString(), true)
);

$call = $this->client->$method($request, $this->meta);
$options = $this->buildGrpcOptions();
$call = $this->client->$method($request, $this->meta, $options);

if (method_exists($call, 'wait')) {
list($response, $status) = $call->wait();
Expand Down Expand Up @@ -152,7 +153,8 @@ protected function doStreamRequest($service, $method, $data = [])

$request = new $requestClass($data);

$call = $this->client->$method($request, $this->meta);
$options = $this->buildGrpcOptions();
$call = $this->client->$method($request, $this->meta, $options);

if (method_exists($call, 'responses')) {
// $status = $call->getStatus();
Expand Down Expand Up @@ -238,7 +240,7 @@ protected function processResponse($service, $method, $response, $resultClass)
$this->logger()->debug('YDB: Received API response [' . $resultClass . '].', json_decode($jsonResult, true));

$result = new $resultClass;
$result->mergeFromJsonString($jsonResult, true);
$result->mergeFromJsonString($jsonResult);
}
}

Expand Down Expand Up @@ -323,6 +325,23 @@ protected function checkDiscovery(){
}
}

/**
* Build gRPC call options including timeout if configured
*
* @return array
*/
protected function buildGrpcOptions()
{
$options = [];

$timeout = $this->ydb->getGrpcTimeout();
if ($timeout !== null) {
$options['timeout'] = $timeout;
}

return $options;
}

public static $ydbExceptions = [
StatusCode::STATUS_CODE_UNSPECIFIED => \YdbPlatform\Ydb\Exceptions\Ydb\StatusCodeUnspecified::class,
StatusCode::BAD_REQUEST => \YdbPlatform\Ydb\Exceptions\Ydb\BadRequestException::class,
Expand Down