Skip to content
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
45 changes: 26 additions & 19 deletions src/Spanner/Admin/Database/V1/DatabaseAdminClient.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright 2016, Google Inc. All rights reserved.
* Copyright 2017, Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -118,7 +118,7 @@ class DatabaseAdminClient
/**
* The code generator version, to be included in the agent header.
*/
const CODEGEN_VERSION = '0.1.0';
const CODEGEN_VERSION = '0.0.5';

private static $instanceNameTemplate;
private static $databaseNameTemplate;
Expand Down Expand Up @@ -249,6 +249,17 @@ private static function getLongRunningDescriptors()
];
}

private static function getGapicVersion()
{
if (file_exists(__DIR__.'/../VERSION')) {
return trim(file_get_contents(__DIR__.'/../VERSION'));
} elseif (class_exists('\Google\Cloud\ServiceBuilder')) {
return \Google\Cloud\ServiceBuilder::VERSION;
} else {
return;
}
}

/**
* Return an OperationsClient object with the same endpoint as $this.
*
Expand Down Expand Up @@ -300,7 +311,7 @@ public function resumeOperation($operationName, $methodName = null)
* Default: a credentials object returned from
* \Grpc\ChannelCredentials::createSsl()
* @type array $scopes A string array of scopes to use when acquiring credentials.
* Default the scopes for the Google Cloud Spanner Database Admin API.
* Default the scopes for the Cloud Spanner Database Admin API.
* @type array $retryingOverride
* An associative array of string => RetryOptions, where the keys
* are method names (e.g. 'createFoo'), that overrides default retrying
Expand All @@ -310,9 +321,6 @@ public function resumeOperation($operationName, $methodName = null)
* that don't use retries. For calls that use retries,
* set the timeout in RetryOptions.
* Default: 30000 (30 seconds)
* @type string $appName The codename of the calling service. Default 'gax'.
* @type string $appVersion The version of the calling service.
* Default: the current version of GAX.
* @type \Google\Auth\CredentialsLoader $credentialsLoader
* A CredentialsLoader object created using the
* Google\Auth library.
Expand All @@ -329,27 +337,26 @@ public function __construct($options = [])
],
'retryingOverride' => null,
'timeoutMillis' => self::DEFAULT_TIMEOUT_MILLIS,
'appName' => 'gax',
'appVersion' => AgentHeaderDescriptor::getGaxVersion(),
'libName' => null,
'libVersion' => null,
];
$options = array_merge($defaultOptions, $options);

if (array_key_exists('operationsClient', $options)) {
$this->operationsClient = $options['operationsClient'];
} else {
$this->operationsClient = new OperationsClient([
'serviceAddress' => $options['serviceAddress'],
'scopes' => $options['scopes'],
]);
$operationsClientOptions = $options;
unset($operationsClientOptions['timeoutMillis']);
unset($operationsClientOptions['retryingOverride']);
$this->operationsClient = new OperationsClient($operationsClientOptions);
}

$gapicVersion = $options['libVersion'] ?: self::getGapicVersion();

$headerDescriptor = new AgentHeaderDescriptor([
'clientName' => $options['appName'],
'clientVersion' => $options['appVersion'],
'codeGenName' => self::CODEGEN_NAME,
'codeGenVersion' => self::CODEGEN_VERSION,
'gaxVersion' => AgentHeaderDescriptor::getGaxVersion(),
'phpVersion' => phpversion(),
'libName' => $options['libName'],
'libVersion' => $options['libVersion'],
'gapicVersion' => $gapicVersion,
]);

$defaultDescriptors = ['headerDescriptor' => $headerDescriptor];
Expand Down Expand Up @@ -701,7 +708,7 @@ public function getDatabase($name, $optionalArgs = [])
* [longrunning.Operation][google.longrunning.Operation]: `<database>/operations/<operation_id>`.
*
* `operation_id` should be unique within the database, and must be
* a valid identifier: `[a-zA-Z][a-zA-Z0-9_]&#42;`. Note that
* a valid identifier: `[a-z][a-z0-9_]&#42;`. Note that
* automatically-generated operation IDs always begin with an
* underscore. If the named operation already exists,
* [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] returns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"interfaces": {
"google.spanner.admin.database.v1.DatabaseAdmin": {
"retry_codes": {
"retry_codes_def": {
"idempotent": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
],
"non_idempotent": []
}
"idempotent": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
],
"non_idempotent": [
"UNAVAILABLE"
]
},
"retry_params": {
"default": {
Expand Down
43 changes: 25 additions & 18 deletions src/Spanner/Admin/Instance/V1/InstanceAdminClient.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright 2016, Google Inc. All rights reserved.
* Copyright 2017, Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -136,7 +136,7 @@ class InstanceAdminClient
/**
* The code generator version, to be included in the agent header.
*/
const CODEGEN_VERSION = '0.1.0';
const CODEGEN_VERSION = '0.0.5';

private static $projectNameTemplate;
private static $instanceConfigNameTemplate;
Expand Down Expand Up @@ -295,6 +295,17 @@ private static function getLongRunningDescriptors()
];
}

private static function getGapicVersion()
{
if (file_exists(__DIR__.'/../VERSION')) {
return trim(file_get_contents(__DIR__.'/../VERSION'));
} elseif (class_exists('\Google\Cloud\ServiceBuilder')) {
return \Google\Cloud\ServiceBuilder::VERSION;
} else {
return;
}
}

/**
* Return an OperationsClient object with the same endpoint as $this.
*
Expand Down Expand Up @@ -346,7 +357,7 @@ public function resumeOperation($operationName, $methodName = null)
* Default: a credentials object returned from
* \Grpc\ChannelCredentials::createSsl()
* @type array $scopes A string array of scopes to use when acquiring credentials.
* Default the scopes for the Google Cloud Spanner Instance Admin API.
* Default the scopes for the Cloud Spanner Instance Admin API.
* @type array $retryingOverride
* An associative array of string => RetryOptions, where the keys
* are method names (e.g. 'createFoo'), that overrides default retrying
Expand All @@ -356,9 +367,6 @@ public function resumeOperation($operationName, $methodName = null)
* that don't use retries. For calls that use retries,
* set the timeout in RetryOptions.
* Default: 30000 (30 seconds)
* @type string $appName The codename of the calling service. Default 'gax'.
* @type string $appVersion The version of the calling service.
* Default: the current version of GAX.
* @type \Google\Auth\CredentialsLoader $credentialsLoader
* A CredentialsLoader object created using the
* Google\Auth library.
Expand All @@ -375,27 +383,26 @@ public function __construct($options = [])
],
'retryingOverride' => null,
'timeoutMillis' => self::DEFAULT_TIMEOUT_MILLIS,
'appName' => 'gax',
'appVersion' => AgentHeaderDescriptor::getGaxVersion(),
'libName' => null,
'libVersion' => null,
];
$options = array_merge($defaultOptions, $options);

if (array_key_exists('operationsClient', $options)) {
$this->operationsClient = $options['operationsClient'];
} else {
$this->operationsClient = new OperationsClient([
'serviceAddress' => $options['serviceAddress'],
'scopes' => $options['scopes'],
]);
$operationsClientOptions = $options;
unset($operationsClientOptions['timeoutMillis']);
unset($operationsClientOptions['retryingOverride']);
$this->operationsClient = new OperationsClient($operationsClientOptions);
}

$gapicVersion = $options['libVersion'] ?: self::getGapicVersion();

$headerDescriptor = new AgentHeaderDescriptor([
'clientName' => $options['appName'],
'clientVersion' => $options['appVersion'],
'codeGenName' => self::CODEGEN_NAME,
'codeGenVersion' => self::CODEGEN_VERSION,
'gaxVersion' => AgentHeaderDescriptor::getGaxVersion(),
'phpVersion' => phpversion(),
'libName' => $options['libName'],
'libVersion' => $options['libVersion'],
'gapicVersion' => $gapicVersion,
]);

$defaultDescriptors = ['headerDescriptor' => $headerDescriptor];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"interfaces": {
"google.spanner.admin.instance.v1.InstanceAdmin": {
"retry_codes": {
"retry_codes_def": {
"idempotent": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
],
"non_idempotent": []
}
"idempotent": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
],
"non_idempotent": [
"UNAVAILABLE"
]
},
"retry_params": {
"default": {
Expand Down
45 changes: 25 additions & 20 deletions src/Spanner/V1/SpannerClient.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright 2016, Google Inc. All rights reserved.
* Copyright 2017, Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,6 @@

namespace Google\Cloud\Spanner\V1;

use DrSlump\Protobuf\Codec\PhpArray;
use Google\GAX\AgentHeaderDescriptor;
use Google\GAX\ApiCallable;
use Google\GAX\CallSettings;
Expand Down Expand Up @@ -105,7 +104,7 @@ class SpannerClient
/**
* The code generator version, to be included in the agent header.
*/
const CODEGEN_VERSION = '0.1.0';
const CODEGEN_VERSION = '0.0.5';

private static $databaseNameTemplate;
private static $sessionNameTemplate;
Expand Down Expand Up @@ -236,6 +235,17 @@ private static function getGrpcStreamingDescriptors()
];
}

private static function getGapicVersion()
{
if (file_exists(__DIR__.'/../VERSION')) {
return trim(file_get_contents(__DIR__.'/../VERSION'));
} elseif (class_exists('\Google\Cloud\ServiceBuilder')) {
return \Google\Cloud\ServiceBuilder::VERSION;
} else {
return;
}
}

// TODO(garrettjones): add channel (when supported in gRPC)
/**
* Constructor.
Expand All @@ -251,7 +261,7 @@ private static function getGrpcStreamingDescriptors()
* Default: a credentials object returned from
* \Grpc\ChannelCredentials::createSsl()
* @type array $scopes A string array of scopes to use when acquiring credentials.
* Default the scopes for the Google Cloud Spanner API.
* Default the scopes for the Cloud Spanner API.
* @type array $retryingOverride
* An associative array of string => RetryOptions, where the keys
* are method names (e.g. 'createFoo'), that overrides default retrying
Expand All @@ -261,9 +271,6 @@ private static function getGrpcStreamingDescriptors()
* that don't use retries. For calls that use retries,
* set the timeout in RetryOptions.
* Default: 30000 (30 seconds)
* @type string $appName The codename of the calling service. Default 'gax'.
* @type string $appVersion The version of the calling service.
* Default: the current version of GAX.
* @type \Google\Auth\CredentialsLoader $credentialsLoader
* A CredentialsLoader object created using the
* Google\Auth library.
Expand All @@ -280,18 +287,17 @@ public function __construct($options = [])
],
'retryingOverride' => null,
'timeoutMillis' => self::DEFAULT_TIMEOUT_MILLIS,
'appName' => 'gax',
'appVersion' => AgentHeaderDescriptor::getGaxVersion(),
'libName' => null,
'libVersion' => null,
];
$options = array_merge($defaultOptions, $options);

$gapicVersion = $options['libVersion'] ?: self::getGapicVersion();

$headerDescriptor = new AgentHeaderDescriptor([
'clientName' => $options['appName'],
'clientVersion' => $options['appVersion'],
'codeGenName' => self::CODEGEN_NAME,
'codeGenVersion' => self::CODEGEN_VERSION,
'gaxVersion' => AgentHeaderDescriptor::getGaxVersion(),
'phpVersion' => phpversion(),
'libName' => $options['libName'],
'libVersion' => $options['libVersion'],
'gapicVersion' => $gapicVersion,
]);

$defaultDescriptors = ['headerDescriptor' => $headerDescriptor];
Expand Down Expand Up @@ -360,10 +366,9 @@ public function __construct($options = [])
*
* Cloud Spanner limits the number of sessions that can exist at any given
* time; thus, it is a good idea to delete idle and/or unneeded sessions.
* Aside from explicit deletes, Cloud Spanner can delete sessions for
* which no operations are sent for more than an hour, or due to
* internal errors. If a session is deleted, requests to it
* return `NOT_FOUND`.
* Aside from explicit deletes, Cloud Spanner can delete sessions for which no
* operations are sent for more than an hour. If a session is deleted,
* requests to it return `NOT_FOUND`.
*
* Idle sessions can be kept alive by sending a trivial SQL query
* periodically, e.g., `"SELECT 1"`.
Expand Down Expand Up @@ -959,7 +964,7 @@ public function streamingRead($session, $table, $columns, $keySet, $optionalArgs
$mergedSettings,
$this->descriptors['streamingRead']
);
// print_r($request->serialize(new PhpArray));exit;

return $callable(
$request,
[],
Expand Down
14 changes: 7 additions & 7 deletions src/Spanner/V1/resources/spanner_client_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"interfaces": {
"google.spanner.v1.Spanner": {
"retry_codes": {
"retry_codes_def": {
"idempotent": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
],
"non_idempotent": []
}
"idempotent": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
],
"non_idempotent": [
"UNAVAILABLE"
]
},
"retry_params": {
"default": {
Expand Down
Loading