From d061c4b6391b08f22000f0853cdad4c69e7045f6 Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Tue, 31 Jan 2017 11:34:33 -0500 Subject: [PATCH] bigtable: incorporate @google-cloud/common-grpc --- packages/bigtable/package.json | 3 ++- packages/bigtable/src/cluster.js | 5 +++-- packages/bigtable/src/family.js | 5 +++-- packages/bigtable/src/index.js | 7 ++++--- packages/bigtable/src/instance.js | 5 +++-- packages/bigtable/src/row.js | 5 +++-- packages/bigtable/src/table.js | 7 ++++--- packages/bigtable/test/cluster.js | 7 +++++-- packages/bigtable/test/family.js | 7 +++++-- packages/bigtable/test/index.js | 9 ++++++--- packages/bigtable/test/instance.js | 8 ++++++-- packages/bigtable/test/row.js | 7 +++++-- packages/bigtable/test/table.js | 11 +++++++---- 13 files changed, 56 insertions(+), 30 deletions(-) diff --git a/packages/bigtable/package.json b/packages/bigtable/package.json index 39a073762ba..2b54fb33419 100644 --- a/packages/bigtable/package.json +++ b/packages/bigtable/package.json @@ -50,7 +50,8 @@ "bigtable" ], "dependencies": { - "@google-cloud/common": "^0.11.0", + "@google-cloud/common": "^0.12.0", + "@google-cloud/common-grpc": "^0.1.1", "arrify": "^1.0.0", "concat-stream": "^1.5.0", "create-error-class": "^3.0.2", diff --git a/packages/bigtable/src/cluster.js b/packages/bigtable/src/cluster.js index 944751f2d29..c8543bf25f5 100644 --- a/packages/bigtable/src/cluster.js +++ b/packages/bigtable/src/cluster.js @@ -21,6 +21,7 @@ 'use strict'; var common = require('@google-cloud/common'); +var commonGrpc = require('@google-cloud/common-grpc'); var format = require('string-format-obj'); var is = require('is'); var util = require('util'); @@ -181,10 +182,10 @@ function Cluster(instance, name) { } }; - common.GrpcServiceObject.call(this, config); + commonGrpc.ServiceObject.call(this, config); } -util.inherits(Cluster, common.GrpcServiceObject); +util.inherits(Cluster, commonGrpc.ServiceObject); /** * Formats zone location. diff --git a/packages/bigtable/src/family.js b/packages/bigtable/src/family.js index bd7c68bbdb3..6e1a1f2e2d5 100644 --- a/packages/bigtable/src/family.js +++ b/packages/bigtable/src/family.js @@ -21,6 +21,7 @@ 'use strict'; var common = require('@google-cloud/common'); +var commonGrpc = require('@google-cloud/common-grpc'); var createErrorClass = require('create-error-class'); var util = require('util'); @@ -158,10 +159,10 @@ function Family(table, name) { } }; - common.GrpcServiceObject.call(this, config); + commonGrpc.ServiceObject.call(this, config); } -util.inherits(Family, common.GrpcServiceObject); +util.inherits(Family, commonGrpc.ServiceObject); /** * Format the Column Family name into the expected proto format. diff --git a/packages/bigtable/src/index.js b/packages/bigtable/src/index.js index 3c3c9102251..65c2af9d332 100644 --- a/packages/bigtable/src/index.js +++ b/packages/bigtable/src/index.js @@ -22,6 +22,7 @@ var arrify = require('arrify'); var common = require('@google-cloud/common'); +var commonGrpc = require('@google-cloud/common-grpc'); var extend = require('extend'); var googleProtoFiles = require('google-proto-files'); var is = require('is'); @@ -351,12 +352,12 @@ function Bigtable(options) { packageJson: require('../package.json') }; - common.GrpcService.call(this, config, options); + commonGrpc.Service.call(this, config, options); this.projectName = 'projects/' + this.projectId; } -util.inherits(Bigtable, common.GrpcService); +util.inherits(Bigtable, commonGrpc.Service); /** * Create a Compute instance. @@ -589,7 +590,7 @@ Bigtable.prototype.instance = function(name) { * @return {Operation} */ Bigtable.prototype.operation = function(name) { - return new common.GrpcOperation(this, name); + return new commonGrpc.Operation(this, name); }; /*! Developer Documentation diff --git a/packages/bigtable/src/instance.js b/packages/bigtable/src/instance.js index bc5c2d8f1ab..75ba532bd73 100644 --- a/packages/bigtable/src/instance.js +++ b/packages/bigtable/src/instance.js @@ -21,6 +21,7 @@ 'use strict'; var common = require('@google-cloud/common'); +var commonGrpc = require('@google-cloud/common-grpc'); var extend = require('extend'); var is = require('is'); var util = require('util'); @@ -234,10 +235,10 @@ function Instance(bigtable, name) { } }; - common.GrpcServiceObject.call(this, config); + commonGrpc.ServiceObject.call(this, config); } -util.inherits(Instance, common.GrpcServiceObject); +util.inherits(Instance, commonGrpc.ServiceObject); /** * Create a cluster. diff --git a/packages/bigtable/src/row.js b/packages/bigtable/src/row.js index 3de6da8124e..a92bd6e8713 100644 --- a/packages/bigtable/src/row.js +++ b/packages/bigtable/src/row.js @@ -22,6 +22,7 @@ var arrify = require('arrify'); var common = require('@google-cloud/common'); +var commonGrpc = require('@google-cloud/common-grpc'); var createErrorClass = require('create-error-class'); var dotProp = require('dot-prop'); var extend = require('extend'); @@ -94,12 +95,12 @@ function Row(table, key) { id: key }; - common.GrpcServiceObject.call(this, config); + commonGrpc.ServiceObject.call(this, config); this.data = {}; } -util.inherits(Row, common.GrpcServiceObject); +util.inherits(Row, commonGrpc.ServiceObject); /** * Formats the row chunks into friendly format. Chunks contain 3 properties: diff --git a/packages/bigtable/src/table.js b/packages/bigtable/src/table.js index 005bce5d64b..68b9c76d99a 100644 --- a/packages/bigtable/src/table.js +++ b/packages/bigtable/src/table.js @@ -22,6 +22,7 @@ var arrify = require('arrify'); var common = require('@google-cloud/common'); +var commonGrpc = require('@google-cloud/common-grpc'); var concat = require('concat-stream'); var flatten = require('lodash.flatten'); var is = require('is'); @@ -180,10 +181,10 @@ function Table(instance, name) { } }; - common.GrpcServiceObject.call(this, config); + commonGrpc.ServiceObject.call(this, config); } -util.inherits(Table, common.GrpcServiceObject); +util.inherits(Table, commonGrpc.ServiceObject); /** * The view to be applied to the returned table's fields. @@ -925,7 +926,7 @@ Table.prototype.mutate = function(entries, callback) { return; } - var status = common.GrpcService.decorateStatus_(entry.status); + var status = commonGrpc.Service.decorateStatus_(entry.status); status.entry = entries[entry.index]; mutationErrors.push(status); diff --git a/packages/bigtable/test/cluster.js b/packages/bigtable/test/cluster.js index 322d6c5c060..1e13075b060 100644 --- a/packages/bigtable/test/cluster.js +++ b/packages/bigtable/test/cluster.js @@ -23,6 +23,7 @@ var proxyquire = require('proxyquire'); var util = require('util'); var common = require('@google-cloud/common'); +var commonGrpc = require('@google-cloud/common-grpc'); var promisified = false; var fakeUtil = extend({}, common.util, { @@ -33,7 +34,7 @@ var fakeUtil = extend({}, common.util, { } }); -var GrpcServiceObject = common.GrpcServiceObject; +var GrpcServiceObject = commonGrpc.ServiceObject; function FakeGrpcServiceObject() { this.calledWith_ = arguments; @@ -62,8 +63,10 @@ describe('Bigtable/Cluster', function() { before(function() { Cluster = proxyquire('../src/cluster.js', { '@google-cloud/common': { - GrpcServiceObject: FakeGrpcServiceObject, util: fakeUtil + }, + '@google-cloud/common-grpc': { + ServiceObject: FakeGrpcServiceObject } }); }); diff --git a/packages/bigtable/test/family.js b/packages/bigtable/test/family.js index 781e9d64c63..05cdc6836f7 100644 --- a/packages/bigtable/test/family.js +++ b/packages/bigtable/test/family.js @@ -24,6 +24,7 @@ var proxyquire = require('proxyquire'); var util = require('@google-cloud/common').util; var common = require('@google-cloud/common'); +var commonGrpc = require('@google-cloud/common-grpc'); var promisified = false; var fakeUtil = extend({}, common.util, { @@ -34,7 +35,7 @@ var fakeUtil = extend({}, common.util, { } }); -var GrpcServiceObject = common.GrpcServiceObject; +var GrpcServiceObject = commonGrpc.ServiceObject; function FakeGrpcServiceObject() { this.calledWith_ = arguments; @@ -63,8 +64,10 @@ describe('Bigtable/Family', function() { before(function() { Family = proxyquire('../src/family.js', { '@google-cloud/common': { - GrpcServiceObject: FakeGrpcServiceObject, util: fakeUtil + }, + '@google-cloud/common-grpc': { + ServiceObject: FakeGrpcServiceObject } }); FamilyError = Family.FamilyError; diff --git a/packages/bigtable/test/index.js b/packages/bigtable/test/index.js index 05e6930e002..2ba0170d433 100644 --- a/packages/bigtable/test/index.js +++ b/packages/bigtable/test/index.js @@ -25,6 +25,7 @@ var proxyquire = require('proxyquire'); var sinon = require('sinon').sandbox.create(); var common = require('@google-cloud/common'); +var commonGrpc = require('@google-cloud/common-grpc'); var Cluster = require('../src/cluster.js'); var Instance = require('../src/instance.js'); @@ -58,7 +59,7 @@ function createFake(Class) { return Fake; } -var FakeGrpcService = createFake(common.GrpcService); +var FakeGrpcService = createFake(commonGrpc.Service); var FakeCluster = createFake(Cluster); var FakeInstance = createFake(Instance); var FakeGrpcOperation = createFake(function() {}); @@ -72,11 +73,13 @@ describe('Bigtable', function() { before(function() { Bigtable = proxyquire('../', { '@google-cloud/common': { - GrpcService: FakeGrpcService, - GrpcOperation: FakeGrpcOperation, paginator: fakePaginator, util: fakeUtil }, + '@google-cloud/common-grpc': { + Service: FakeGrpcService, + Operation: FakeGrpcOperation + }, './cluster.js': FakeCluster, './instance.js': FakeInstance }); diff --git a/packages/bigtable/test/instance.js b/packages/bigtable/test/instance.js index d464c67292a..932ab3cc2ff 100644 --- a/packages/bigtable/test/instance.js +++ b/packages/bigtable/test/instance.js @@ -23,7 +23,9 @@ var proxyquire = require('proxyquire'); var util = require('util'); var common = require('@google-cloud/common'); -var GrpcServiceObject = common.GrpcServiceObject; +var commonGrpc = require('@google-cloud/common-grpc'); +var GrpcServiceObject = commonGrpc.ServiceObject; + var Cluster = require('../src/cluster.js'); var Family = require('../src/family.js'); var Table = require('../src/table.js'); @@ -81,10 +83,12 @@ describe('Bigtable/Instance', function() { before(function() { Instance = proxyquire('../src/instance.js', { '@google-cloud/common': { - GrpcServiceObject: FakeGrpcServiceObject, paginator: fakePaginator, util: fakeUtil }, + '@google-cloud/common-grpc': { + ServiceObject: FakeGrpcServiceObject + }, './cluster.js': FakeCluster, './family.js': FakeFamily, './table.js': FakeTable diff --git a/packages/bigtable/test/row.js b/packages/bigtable/test/row.js index 41a939e1e3f..1c1db8f6e2c 100644 --- a/packages/bigtable/test/row.js +++ b/packages/bigtable/test/row.js @@ -23,7 +23,8 @@ var proxyquire = require('proxyquire'); var sinon = require('sinon').sandbox.create(); var common = require('@google-cloud/common'); -var GrpcServiceObject = common.GrpcServiceObject; +var commonGrpc = require('@google-cloud/common-grpc'); +var GrpcServiceObject = commonGrpc.ServiceObject; var Mutation = require('../src/mutation.js'); var promisified = false; @@ -82,9 +83,11 @@ describe('Bigtable/Row', function() { before(function() { Row = proxyquire('../src/row.js', { '@google-cloud/common': { - GrpcServiceObject: FakeGrpcServiceObject, util: fakeUtil }, + '@google-cloud/common-grpc': { + ServiceObject: FakeGrpcServiceObject, + }, './mutation.js': FakeMutation, './filter.js': FakeFilter }); diff --git a/packages/bigtable/test/table.js b/packages/bigtable/test/table.js index c3caff4ef7e..9d70a6fb9aa 100644 --- a/packages/bigtable/test/table.js +++ b/packages/bigtable/test/table.js @@ -26,6 +26,7 @@ var Stream = require('stream').PassThrough; var through = require('through2'); var common = require('@google-cloud/common'); +var commonGrpc = require('@google-cloud/common-grpc'); var Family = require('../src/family.js'); var Mutation = require('../src/mutation.js'); var Row = require('../src/row.js'); @@ -51,8 +52,8 @@ function createFake(Class) { return Fake; } -var FakeGrpcService = createFake(common.GrpcService); -var FakeGrpcServiceObject = createFake(common.GrpcServiceObject); +var FakeGrpcService = createFake(commonGrpc.Service); +var FakeGrpcServiceObject = createFake(commonGrpc.ServiceObject); var FakeFamily = createFake(Family); FakeFamily.formatRule_ = sinon.spy(function(rule) { @@ -98,10 +99,12 @@ describe('Bigtable/Table', function() { before(function() { Table = proxyquire('../src/table.js', { '@google-cloud/common': { - GrpcService: FakeGrpcService, - GrpcServiceObject: FakeGrpcServiceObject, util: fakeUtil }, + '@google-cloud/common-grpc': { + Service: FakeGrpcService, + ServiceObject: FakeGrpcServiceObject + }, './family.js': FakeFamily, './mutation.js': FakeMutation, './filter.js': FakeFilter,