Skip to content

Commit

Permalink
Merge pull request #2 from yash30201/datastore-gapic-client-instantia…
Browse files Browse the repository at this point in the history
…tion

feat(Datastore): Enable Gapic Client support for Request Handler.
  • Loading branch information
yash30201 authored Mar 26, 2024
2 parents 689931c + 49b222c commit 5485f36
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ keys/
.testing
.split
__pycache__

# VS Code local workspace settings
.vscode
18 changes: 16 additions & 2 deletions Datastore/src/DatastoreClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -90,12 +92,17 @@ class DatastoreClient
{
use ArrayTrait;
use ClientTrait;
use ClientOptionsTrait;
use DatastoreTrait;

const VERSION = '1.27.2';

const FULL_CONTROL_SCOPE = 'https://www.googleapis.com/auth/datastore';

private const GAPIC_KEYS = [
DatastoreGapicClient::class
];

/**
* @deprecated
* @var ConnectionInterface
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 5485f36

Please sign in to comment.