From 7215b2e1d5122e03707e6667ef84449bbbfd093f Mon Sep 17 00:00:00 2001 From: yash30201 <54198301+yash30201@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:35:36 +0000 Subject: [PATCH] Enable Gapic Client support for Request Handler. --- .gitignore | 3 +++ Datastore/src/DatastoreClient.php | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 87c5820d73ce..4ffcd0b6a8eb 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,6 @@ keys/ .testing .split __pycache__ + +# VS Code local workspace settings +.vscode diff --git a/Datastore/src/DatastoreClient.php b/Datastore/src/DatastoreClient.php index be00366fbc97..7296e17b6bed 100644 --- a/Datastore/src/DatastoreClient.php +++ b/Datastore/src/DatastoreClient.php @@ -18,8 +18,9 @@ namespace Google\Cloud\Datastore; use DomainException; +use Google\ApiCore\ArrayTrait; +use Google\ApiCore\ClientOptionsTrait; use Google\Auth\FetchAuthTokenInterface; -use Google\Cloud\Core\ArrayTrait; use Google\Cloud\Core\ClientTrait; use Google\Cloud\Core\Int64; use Google\Cloud\Datastore\Connection\ConnectionInterface; @@ -30,6 +31,7 @@ use Google\Cloud\Datastore\Query\GqlQuery; use Google\Cloud\Datastore\Query\Query; use Google\Cloud\Datastore\Query\QueryInterface; +use Google\Cloud\Datastore\V1\Client\DatastoreClient as DatastoreGapicClient; use InvalidArgumentException; use Psr\Cache\CacheItemPoolInterface; use Psr\Http\Message\StreamInterface; @@ -90,12 +92,17 @@ class DatastoreClient { use ArrayTrait; use ClientTrait; + use ClientOptionsTrait; use DatastoreTrait; const VERSION = '1.28.0'; const FULL_CONTROL_SCOPE = 'https://www.googleapis.com/auth/datastore'; + private const GAPIC_KEYS = [ + DatastoreGapicClient::class + ]; + /** * @deprecated * @var ConnectionInterface @@ -166,8 +173,15 @@ public function __construct(array $config = []) 'scopes' => [self::FULL_CONTROL_SCOPE], 'projectIdRequired' => true, 'hasEmulator' => (bool) $emulatorHost, - 'emulatorHost' => $emulatorHost + 'emulatorHost' => $emulatorHost, + 'transportConfig' => [ + 'grpc' => [ + // increase default limit to 4MB to prevent metadata exhausted errors + 'stubOpts' => ['grpc.max_metadata_size' => 4 * 1024 * 1024,] + ], + ], ]; + $config = $this->buildClientOptions($config); $config = $this->configureAuthentication($config); $this->connection = $connectionType === 'grpc'