Skip to content
Closed
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
15 changes: 7 additions & 8 deletions packages/spanner/src/v1/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -26,10 +26,9 @@ function v1(options) {
var gaxGrpc = gax.grpc(options);
return spannerClient(gaxGrpc);
}

v1.GAPIC_VERSION = '0.0.5';
v1.SERVICE_ADDRESS = spannerClient.SERVICE_ADDRESS;
v1.ALL_SCOPES = spannerClient.ALL_SCOPES;
v1.admin = {

This comment was marked as spam.

This comment was marked as spam.

instance: require('../admin/instance/v1'),
database: require('../admin/database/v1')
};
module.exports = v1;

module.exports = v1;
145 changes: 96 additions & 49 deletions packages/spanner/src/v1/spanner_client.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -35,7 +35,7 @@ var SERVICE_ADDRESS = 'spanner.googleapis.com';

var DEFAULT_SERVICE_PORT = 443;

var CODE_GEN_NAME_VERSION = 'gapic/0.7.1';
var CODE_GEN_NAME_VERSION = 'gapic/0.0.5';

var STREAM_DESCRIPTORS = {
executeStreamingSql: new gax.StreamDescriptor(gax.StreamType.SERVER_STREAMING),
Expand All @@ -57,15 +57,6 @@ var ALL_SCOPES = [
* The Cloud Spanner API can be used to manage sessions and execute
* transactions on data stored in Cloud Spanner databases.
*
* This will be created through a builder function which can be obtained by the module.
* See the following example of how to initialize the module and how to access to the builder.
* @see {@link spannerClient}
*
* @example
* var spannerV1 = require('@google-cloud/spanner').v1({
* // optional auth parameters.
* });
* var client = spannerV1.spannerClient();
*
* @class
*/
Expand Down Expand Up @@ -148,6 +139,23 @@ SpannerClient.prototype.databasePath = function(project, instance, database) {
});
};

/**
* Returns a fully-qualified session resource name string.
* @param {String} project
* @param {String} instance
* @param {String} database
* @param {String} session
* @returns {String}
*/
SpannerClient.prototype.sessionPath = function(project, instance, database, session) {
return SESSION_PATH_TEMPLATE.render({
project: project,
instance: instance,
database: database,
session: session
});
};

/**
* Parses the databaseName from a database resource.
* @param {String} databaseName
Expand Down Expand Up @@ -178,23 +186,6 @@ SpannerClient.prototype.matchDatabaseFromDatabaseName = function(databaseName) {
return DATABASE_PATH_TEMPLATE.match(databaseName).database;
};

/**
* Returns a fully-qualified session resource name string.
* @param {String} project
* @param {String} instance
* @param {String} database
* @param {String} session
* @returns {String}
*/
SpannerClient.prototype.sessionPath = function(project, instance, database, session) {
return SESSION_PATH_TEMPLATE.render({
project: project,
instance: instance,
database: database,
session: session
});
};

/**
* Parses the sessionName from a session resource.
* @param {String} sessionName
Expand Down Expand Up @@ -237,7 +228,7 @@ SpannerClient.prototype.matchSessionFromSessionName = function(sessionName) {

/**
* Get the project ID used by this class.
* @aram {function(Error, string)} callback - the callback to be called with
* @param {function(Error, string)} callback - the callback to be called with
* the current project Id.
*/
SpannerClient.prototype.getProjectId = function(callback) {
Expand Down Expand Up @@ -284,12 +275,18 @@ SpannerClient.prototype.getProjectId = function(callback) {
*
* @example
*
* var client = spannerV1.spannerClient();
* var spanner = require('@google-cloud/spanner');
*
* var client = spanner.v1({
* // optional auth parameters.
* });
*
* var formattedDatabase = client.databasePath("[PROJECT]", "[INSTANCE]", "[DATABASE]");
* client.createSession({database: formattedDatabase}).then(function(responses) {
* var response = responses[0];
* // doThingsWith(response)
* }).catch(function(err) {
* })
* .catch(function(err) {
* console.error(err);
* });
*/
Expand Down Expand Up @@ -327,12 +324,18 @@ SpannerClient.prototype.createSession = function(request, options, callback) {
*
* @example
*
* var client = spannerV1.spannerClient();
* var spanner = require('@google-cloud/spanner');
*
* var client = spanner.v1({
* // optional auth parameters.
* });
*
* var formattedName = client.sessionPath("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
* client.getSession({name: formattedName}).then(function(responses) {
* var response = responses[0];
* // doThingsWith(response)
* }).catch(function(err) {
* })
* .catch(function(err) {
* console.error(err);
* });
*/
Expand Down Expand Up @@ -365,7 +368,12 @@ SpannerClient.prototype.getSession = function(request, options, callback) {
*
* @example
*
* var client = spannerV1.spannerClient();
* var spanner = require('@google-cloud/spanner');
*
* var client = spanner.v1({
* // optional auth parameters.
* });
*
* var formattedName = client.sessionPath("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
* client.deleteSession({name: formattedName}).catch(function(err) {
* console.error(err);
Expand Down Expand Up @@ -458,7 +466,12 @@ SpannerClient.prototype.deleteSession = function(request, options, callback) {
*
* @example
*
* var client = spannerV1.spannerClient();
* var spanner = require('@google-cloud/spanner');
*
* var client = spanner.v1({
* // optional auth parameters.
* });
*
* var formattedSession = client.sessionPath("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
* var sql = '';
* var request = {
Expand All @@ -468,7 +481,8 @@ SpannerClient.prototype.deleteSession = function(request, options, callback) {
* client.executeSql(request).then(function(responses) {
* var response = responses[0];
* // doThingsWith(response)
* }).catch(function(err) {
* })
* .catch(function(err) {
* console.error(err);
* });
*/
Expand Down Expand Up @@ -548,15 +562,20 @@ SpannerClient.prototype.executeSql = function(request, options, callback) {
*
* @example
*
* var client = spannerV1.spannerClient();
* var spanner = require('@google-cloud/spanner');
*
* var client = spanner.v1({
* // optional auth parameters.
* });
*
* var formattedSession = client.sessionPath("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
* var sql = '';
* var request = {
* session: formattedSession,
* sql: sql
* };
* client.executeStreamingSql(request).on('data', function(response) {
* // doThingsWith(response)
* // doThingsWith(response)
* });
*/
SpannerClient.prototype.executeStreamingSql = function(request, options) {
Expand Down Expand Up @@ -636,7 +655,12 @@ SpannerClient.prototype.executeStreamingSql = function(request, options) {
*
* @example
*
* var client = spannerV1.spannerClient();
* var spanner = require('@google-cloud/spanner');
*
* var client = spanner.v1({
* // optional auth parameters.
* });
*
* var formattedSession = client.sessionPath("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
* var table = '';
* var columns = [];
Expand All @@ -650,7 +674,8 @@ SpannerClient.prototype.executeStreamingSql = function(request, options) {
* client.read(request).then(function(responses) {
* var response = responses[0];
* // doThingsWith(response)
* }).catch(function(err) {
* })
* .catch(function(err) {
* console.error(err);
* });
*/
Expand Down Expand Up @@ -722,7 +747,12 @@ SpannerClient.prototype.read = function(request, options, callback) {
*
* @example
*
* var client = spannerV1.spannerClient();
* var spanner = require('@google-cloud/spanner');
*
* var client = spanner.v1({
* // optional auth parameters.
* });
*
* var formattedSession = client.sessionPath("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
* var table = '';
* var columns = [];
Expand All @@ -734,7 +764,7 @@ SpannerClient.prototype.read = function(request, options, callback) {
* keySet: keySet
* };
* client.streamingRead(request).on('data', function(response) {
* // doThingsWith(response)
* // doThingsWith(response)
* });
*/
SpannerClient.prototype.streamingRead = function(request, options) {
Expand Down Expand Up @@ -772,7 +802,12 @@ SpannerClient.prototype.streamingRead = function(request, options) {
*
* @example
*
* var client = spannerV1.spannerClient();
* var spanner = require('@google-cloud/spanner');
*
* var client = spanner.v1({
* // optional auth parameters.
* });
*
* var formattedSession = client.sessionPath("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
* var options = {};
* var request = {
Expand All @@ -782,7 +817,8 @@ SpannerClient.prototype.streamingRead = function(request, options) {
* client.beginTransaction(request).then(function(responses) {
* var response = responses[0];
* // doThingsWith(response)
* }).catch(function(err) {
* })
* .catch(function(err) {
* console.error(err);
* });
*/
Expand Down Expand Up @@ -845,7 +881,12 @@ SpannerClient.prototype.beginTransaction = function(request, options, callback)
*
* @example
*
* var client = spannerV1.spannerClient();
* var spanner = require('@google-cloud/spanner');
*
* var client = spanner.v1({
* // optional auth parameters.
* });
*
* var formattedSession = client.sessionPath("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
* var mutations = [];
* var request = {
Expand All @@ -855,7 +896,8 @@ SpannerClient.prototype.beginTransaction = function(request, options, callback)
* client.commit(request).then(function(responses) {
* var response = responses[0];
* // doThingsWith(response)
* }).catch(function(err) {
* })
* .catch(function(err) {
* console.error(err);
* });
*/
Expand Down Expand Up @@ -897,7 +939,12 @@ SpannerClient.prototype.commit = function(request, options, callback) {
*
* @example
*
* var client = spannerV1.spannerClient();
* var spanner = require('@google-cloud/spanner');
*
* var client = spanner.v1({
* // optional auth parameters.
* });
*
* var formattedSession = client.sessionPath("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]");
* var transactionId = '';
* var request = {
Expand Down Expand Up @@ -953,4 +1000,4 @@ function SpannerClientBuilder(gaxGrpc) {
}
module.exports = SpannerClientBuilder;
module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS;
module.exports.ALL_SCOPES = ALL_SCOPES;
module.exports.ALL_SCOPES = ALL_SCOPES;
6 changes: 3 additions & 3 deletions packages/spanner/src/v1/spanner_client_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"initial_rpc_timeout_millis": 3600000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 3600000,
"total_timeout_millis": 3600000
"total_timeout_millis": 36000000
}
},
"methods": {
Expand All @@ -55,7 +55,7 @@
"ExecuteStreamingSql": {
"timeout_millis": 3600000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "long_running"
"retry_params_name": "default"
},
"Read": {
"timeout_millis": 30000,
Expand All @@ -65,7 +65,7 @@
"StreamingRead": {
"timeout_millis": 3600000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "long_running"
"retry_params_name": "default"
},
"BeginTransaction": {
"timeout_millis": 30000,
Expand Down