Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choose rest over grpc for now. #477

Merged
merged 1 commit into from
May 4, 2017
Merged
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions src/Core/ClientTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,21 @@ trait ClientTrait
private $projectId;

/**
* Get either a gRPC or REST connection based on the provided config
* and system settings.
* Get either a gRPC or REST connection based on the provided config.
*
*
* @param array $config
* @return string
* @throws GoogleException
*/
private function getConnectionType(array $config)
{
list($isGrpcExtensionLoaded, $isGrpcLibraryLoaded) = $this->getGrpcDependencyStatus();
$defaultTransport = $isGrpcExtensionLoaded && $isGrpcLibraryLoaded ? 'grpc' : 'rest';
$transport = isset($config['transport'])
? strtolower($config['transport'])
: $defaultTransport;

: 'rest';
if ($transport === 'grpc') {
list($isGrpcExtensionLoaded, $isGrpcLibraryLoaded) =
$this->getGrpcDependencyStatus();
if (!$isGrpcExtensionLoaded || !$isGrpcLibraryLoaded) {
throw new GoogleException(
'gRPC support has been requested but required dependencies ' .
Expand Down
3 changes: 1 addition & 2 deletions src/Logging/LoggingClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ class LoggingClient
* **Defaults to** `3`.
* @type array $scopes Scopes to be used for the request.
* @type string $transport The transport type used for requests. May be
* either `grpc` or `rest`. **Defaults to** `grpc` if gRPC support
* is detected on the system.
* either `grpc` or `rest`. **Defaults to** `rest`.
* }
*/
public function __construct(array $config = [])
Expand Down
3 changes: 1 addition & 2 deletions src/PubSub/PubSubClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ class PubSubClient
* **Defaults to** `3`.
* @type array $scopes Scopes to be used for the request.
* @type string $transport The transport type used for requests. May be
* either `grpc` or `rest`. **Defaults to** `grpc` if gRPC support
* is detected on the system.
* either `grpc` or `rest`. **Defaults to** `rest`.
* }
* @throws \InvalidArgumentException
*/
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/Core/ClientTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function dependencyStatusProvider()
[
[true, true],
[],
'grpc'
'rest'
],
[
[false, false],
Expand All @@ -63,6 +63,11 @@ public function dependencyStatusProvider()
[false, true],
[],
'rest'
],
[
[true, true],
['transport' => 'grpc'],
'grpc'
]
];
}
Expand Down
7 changes: 2 additions & 5 deletions tests/unit/PubSub/PubSubClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,11 @@ public function setUp()
]);
}

public function testUsesGrpcConnectionByDefault()
public function testUsesRestConnectionByDefault()
{
if (!extension_loaded('grpc')) {
$this->markTestSkipped('Must have the grpc extension installed to run this test.');
}
$client = new PubSubClientStub(['projectId' => 'project']);

$this->assertInstanceOf(Grpc::class, $client->getConnection());
$this->assertInstanceOf(Rest::class, $client->getConnection());
}

public function testCreateTopic()
Expand Down