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

Add LRO support #42

Merged
merged 24 commits into from
Jan 3, 2017
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
547fbfd
DO NOT MERGE: LRO sample
michaelbausor Oct 31, 2016
fa54b7c
Update with getProtoResponse and other samples
michaelbausor Oct 31, 2016
4f66cb4
LRO updates
michaelbausor Nov 16, 2016
8c3e427
remove lro sample
michaelbausor Nov 21, 2016
fa113f8
Regenerate operations API
michaelbausor Nov 22, 2016
bb333ba
Start adding polling
michaelbausor Nov 22, 2016
68bfcc4
Restructure, add comments
michaelbausor Dec 4, 2016
53198df
Update operations api and response object
michaelbausor Dec 13, 2016
e4bffe5
Fix syntax error
michaelbausor Dec 13, 2016
24d8b81
Fix syntax error
michaelbausor Dec 14, 2016
824a64c
Add tests
michaelbausor Dec 20, 2016
7f6c838
Update docs, composer
michaelbausor Dec 20, 2016
7c899c5
remove handler from pollUntilComplete
michaelbausor Dec 20, 2016
ff8a734
Doc fixes
michaelbausor Dec 20, 2016
3cd9959
Regenerate OperationsClient without scopes and serviceAddress
michaelbausor Dec 21, 2016
ec982e2
Update tests to set serviceAddress and scopes in OperationsClient
michaelbausor Dec 21, 2016
59c746d
Address PR comments
michaelbausor Dec 22, 2016
a12e50f
Add max duration setting to pollUntilComplete
michaelbausor Dec 22, 2016
3eef214
Add operationSucceeded and operationFailed functions
michaelbausor Dec 23, 2016
774079a
Update OperationsClient namespace
michaelbausor Dec 27, 2016
c84d412
Update namespace in import
michaelbausor Dec 27, 2016
aceb645
Change LRO namespace to camel case
michaelbausor Dec 27, 2016
497320b
Camel case Longrunning namespace
michaelbausor Dec 27, 2016
545efa8
Edit OperationsClient comments
michaelbausor Dec 29, 2016
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
},
"autoload": {
"psr-4": {
"Google\\GAX\\":"src/"
"Google\\GAX\\":"src/",
"Google\\Longrunning\\":"src/Longrunning/"

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

},
"classmap": ["src/generated", "src/generated/well-known-types"]
}
Expand Down
28 changes: 24 additions & 4 deletions src/ApiCallable.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ private static function setPageStreaming($callable, $pageStreamingDescriptor)
return $inner;
}

private static function setLongRunnning($callable, $longRunningDescriptor)
{
$inner = function () use ($callable, $longRunningDescriptor) {
$response = call_user_func_array($callable, func_get_args());
$name = $response->getName();
$client = $longRunningDescriptor['operationsClient'];
$options = $longRunningDescriptor + [
'lastProtoResponse' => $response,
];
return new OperationResponse($name, $client, $options);
};
return $inner;
}

private static function setCustomHeader($callable, $headerDescriptor)
{
$inner = function () use ($callable, $headerDescriptor) {
Expand All @@ -138,16 +152,18 @@ private static function setCustomHeader($callable, $headerDescriptor)
}

/**
* @param Grpc\BaseStub $stub the gRPC stub to make calls through.
* @param \Grpc\BaseStub $stub the gRPC stub to make calls through.
* @param string $methodName the method name on the stub to call.
* @param Google\GAX\CallSettings $settings the call settings to use for this call.
* @param \Google\GAX\CallSettings $settings the call settings to use for this call.
* @param array $options {
* Optional.
* @type Google\GAX\PageStreamingDescriptor $pageStreamingDescriptor
* @type \Google\GAX\PageStreamingDescriptor $pageStreamingDescriptor
* the descriptor used for page-streaming.
* @type Google\GAX\AgentHeaderDescriptor $headerDescriptor
* @type \Google\GAX\AgentHeaderDescriptor $headerDescriptor
* the descriptor used for creating GAPIC header.
* }
*
* @return callable
*/
public static function createApiCall($stub, $methodName, CallSettings $settings, $options = [])
{
Expand Down Expand Up @@ -176,6 +192,10 @@ public static function createApiCall($stub, $methodName, CallSettings $settings,
$apiCall = self::setPageStreaming($apiCall, $options['pageStreamingDescriptor']);
}

if (array_key_exists('longRunningDescriptor', $options)) {
$apiCall = self::setLongRunnning($apiCall, $options['longRunningDescriptor']);
}

if (array_key_exists('headerDescriptor', $options)) {
$apiCall = self::setCustomHeader($apiCall, $options['headerDescriptor']);
}
Expand Down
8 changes: 4 additions & 4 deletions src/GrpcCredentialsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class GrpcCredentialsHelper
* will be passed as optional arguments to Google\Auth\FetchAuthTokenCache
* when caching is enabled.
*
* @var Google\Auth\CredentialsLoader $credentialsLoader
* @var \Google\Auth\CredentialsLoader $credentialsLoader
* A user-created CredentialsLoader object. Defaults to using
* ApplicationDefaultCredentials
* @var boolean $enableCaching
Expand Down Expand Up @@ -111,7 +111,7 @@ public function createCallCredentialsCallback()
/**
* Creates a gRPC client stub.
*
* @param function $generatedCreateStub
* @param callable $generatedCreateStub
* Function callback which must accept two arguments ($hostname, $opts)
* and return an instance of the stub of the specific API to call.
* Generally, this should just call the stub's constructor and return
Expand All @@ -121,10 +121,10 @@ public function createCallCredentialsCallback()
* @param array $options {
* Optional. Options for configuring the gRPC stub.
*
* @type Grpc\ChannelCredentials $sslCreds
* @type \Grpc\ChannelCredentials $sslCreds
* A `ChannelCredentials` for use with an SSL-enabled channel.
* Default: a credentials object returned from
* Grpc\ChannelCredentials::createSsl()
* \Grpc\ChannelCredentials::createSsl()
* }
*/
public function createStub($generatedCreateStub, $serviceAddress, $port, $options = [])
Expand Down
Loading