From 11acc946e1317732ca797e88eb906e4a7166ba32 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 1 Oct 2026 00:22:04 +0000 Subject: [PATCH] feat(Gax)!: remove google/grpc-gcp dependency and gcpApiConfigPath --- Gax/composer.json | 1 - Gax/src/ClientOptionsTrait.php | 37 ++----------------- .../Grpc/ServerStreamingCallWrapper.php | 5 +-- Gax/tests/Unit/ClientOptionsTraitTest.php | 11 ------ Gax/tests/Unit/GapicClientTraitTest.php | 1 - .../resources/test_service_grpc_config.json | 17 --------- composer.json | 1 - 7 files changed, 5 insertions(+), 68 deletions(-) delete mode 100644 Gax/tests/Unit/testdata/resources/test_service_grpc_config.json diff --git a/Gax/composer.json b/Gax/composer.json index f904c2ffe5a3..a29a5a553b4d 100644 --- a/Gax/composer.json +++ b/Gax/composer.json @@ -10,7 +10,6 @@ "require": { "php": "^8.2", "google/auth": "^1.53", - "google/grpc-gcp": "^0.4", "grpc/grpc": "^1.38", "google/protobuf": "^4.31||^5.34", "guzzlehttp/promises": "^2.0.3||^3.0", diff --git a/Gax/src/ClientOptionsTrait.php b/Gax/src/ClientOptionsTrait.php index 9384ca7a96e4..df132a37742c 100644 --- a/Gax/src/ClientOptionsTrait.php +++ b/Gax/src/ClientOptionsTrait.php @@ -38,8 +38,6 @@ use Google\Auth\FetchAuthTokenInterface; use Google\Auth\GetUniverseDomainInterface; use Google\Auth\HttpHandler\HttpHandlerFactory; -use Grpc\Gcp\ApiConfig; -use Grpc\Gcp\Config; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; @@ -65,14 +63,6 @@ private static function getGapicVersion(array $options) return self::$gapicVersionFromFile; } - private static function initGrpcGcpConfig(string $hostName, string $confPath) - { - $apiConfig = new ApiConfig(); - $apiConfig->mergeFromJsonString(file_get_contents($confPath)); - $config = new Config($hostName, $apiConfig); - return $config; - } - /** * Get default options. This function should be "overridden" by clients using late static * binding to provide default options to the client. @@ -93,11 +83,9 @@ private static function getClientDefaults() * 1. Set default client option values * 2. Set default logger (and log user-supplied configuration options) * 3. Set default transport configuration - * 4. Call "modifyClientOptions" (for backwards compatibility) - * 5. Use "defaultScopes" when custom endpoint is supplied - * 6. Load mTLS from the environment if configured - * 7. Resolve endpoint based on universe domain template when possible - * 8. Load sysvshm grpc config when possible + * 4. Use "defaultScopes" when custom endpoint is supplied + * 5. Load mTLS from the environment if configured + * 6. Resolve endpoint based on universe domain template when possible */ private function buildClientOptions(array|ClientOptions $options) { @@ -253,25 +241,6 @@ private function buildClientOptions(array|ClientOptions $options) } } - if (extension_loaded('sysvshm') - && isset($options['gcpApiConfigPath']) - && file_exists($options['gcpApiConfigPath']) - && !empty($apiEndpoint) - ) { - $grpcGcpConfig = self::initGrpcGcpConfig( - $apiEndpoint, - $options['gcpApiConfigPath'] - ); - - if (!array_key_exists('stubOpts', $options['transportConfig']['grpc'])) { - $options['transportConfig']['grpc']['stubOpts'] = []; - } - - $options['transportConfig']['grpc']['stubOpts'] += [ - 'grpc_call_invoker' => $grpcGcpConfig->callInvoker() - ]; - } - $options['apiEndpoint'] = $apiEndpoint; return $options; diff --git a/Gax/src/Transport/Grpc/ServerStreamingCallWrapper.php b/Gax/src/Transport/Grpc/ServerStreamingCallWrapper.php index bdf49d624f1d..74ccf1429afc 100644 --- a/Gax/src/Transport/Grpc/ServerStreamingCallWrapper.php +++ b/Gax/src/Transport/Grpc/ServerStreamingCallWrapper.php @@ -33,7 +33,6 @@ namespace Google\ApiCore\Transport\Grpc; use Google\ApiCore\ServerStreamingCallInterface; -use Grpc\Gcp\GCPServerStreamCall; use Grpc\ServerStreamingCall; /** @@ -43,12 +42,12 @@ class ServerStreamingCallWrapper implements ServerStreamingCallInterface { /** - * @var ServerStreamingCall|GCPServerStreamCall + * @var ServerStreamingCall */ private object $stream; /** - * @param ServerStreamingCall|GCPServerStreamCall $stream + * @param ServerStreamingCall $stream */ public function __construct($stream) { diff --git a/Gax/tests/Unit/ClientOptionsTraitTest.php b/Gax/tests/Unit/ClientOptionsTraitTest.php index a5c9d964a57f..cd400eec4167 100644 --- a/Gax/tests/Unit/ClientOptionsTraitTest.php +++ b/Gax/tests/Unit/ClientOptionsTraitTest.php @@ -40,8 +40,6 @@ use Google\Auth\FetchAuthTokenInterface; use Google\Auth\GetUniverseDomainInterface; use Google\Auth\Logging\StdOutLogger; -use Grpc\Gcp\ApiConfig; -use Grpc\Gcp\Config; use InvalidArgumentException; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; @@ -84,7 +82,6 @@ public static function getClientDefaults() { return [ 'apiEndpoint' => 'test.address.com:443', - 'gcpApiConfigPath' => __DIR__ . '/testdata/resources/test_service_grpc_config.json', ]; } }; @@ -242,21 +239,13 @@ public function testBuildClientOptions($options, $expectedUpdatedOptions) public function buildClientOptionsProvider() { - $apiConfig = new ApiConfig(); - $apiConfig->mergeFromJsonString( - file_get_contents(__DIR__ . '/testdata/resources/test_service_grpc_config.json') - ); - $grpcGcpConfig = new Config('test.address.com:443', $apiConfig); - $defaultOptions = [ 'apiEndpoint' => 'test.address.com:443', - 'gcpApiConfigPath' => __DIR__ . '/testdata/resources/test_service_grpc_config.json', 'disableRetries' => false, 'transport' => null, 'transportConfig' => [ 'grpc' => [ 'stubOpts' => [ - 'grpc_call_invoker' => $grpcGcpConfig->callInvoker(), 'grpc.service_config_disable_resolution' => 1, ], 'logger' => null, diff --git a/Gax/tests/Unit/GapicClientTraitTest.php b/Gax/tests/Unit/GapicClientTraitTest.php index 3715a14c82cd..d23b98d97b9c 100644 --- a/Gax/tests/Unit/GapicClientTraitTest.php +++ b/Gax/tests/Unit/GapicClientTraitTest.php @@ -55,7 +55,6 @@ use Google\Auth\FetchAuthTokenInterface; use Google\LongRunning\Client\OperationsClient; use Google\LongRunning\Operation; -use Grpc\Gcp\Config; use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Promise\PromiseInterface; use PHPUnit\Framework\TestCase; diff --git a/Gax/tests/Unit/testdata/resources/test_service_grpc_config.json b/Gax/tests/Unit/testdata/resources/test_service_grpc_config.json deleted file mode 100644 index 0e46c53967eb..000000000000 --- a/Gax/tests/Unit/testdata/resources/test_service_grpc_config.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "channelPool": { - "maxSize": 10, - "maxConcurrentStreamsLowWatermark": 1 - }, - "method": [ - { - "name": [ - "/google.test.v1.Test/TestMethod" - ], - "affinity": { - "command": "BIND", - "affinityKey": "key" - } - } - ] -} \ No newline at end of file diff --git a/composer.json b/composer.json index 46ec3b004b25..8444556fa2f9 100644 --- a/composer.json +++ b/composer.json @@ -69,7 +69,6 @@ "grpc/grpc": "^1.13", "google/common-protos": "^4.4", "google/protobuf": "^4.31||^5.34", - "google/grpc-gcp": "^0.4", "ramsey/uuid": "^4.0", "open-telemetry/sdk": "^1.13", "open-telemetry/exporter-otlp": "^1.4"