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

bigtable: incorporate @google-cloud/common-grpc #1948

Merged
merged 1 commit into from
Jan 31, 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
3 changes: 2 additions & 1 deletion packages/bigtable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions packages/bigtable/src/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions packages/bigtable/src/family.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions packages/bigtable/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions packages/bigtable/src/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions packages/bigtable/src/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions packages/bigtable/src/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions packages/bigtable/test/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -33,7 +34,7 @@ var fakeUtil = extend({}, common.util, {
}
});

var GrpcServiceObject = common.GrpcServiceObject;
var GrpcServiceObject = commonGrpc.ServiceObject;

function FakeGrpcServiceObject() {
this.calledWith_ = arguments;
Expand Down Expand Up @@ -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
}
});
});
Expand Down
7 changes: 5 additions & 2 deletions packages/bigtable/test/family.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -34,7 +35,7 @@ var fakeUtil = extend({}, common.util, {
}
});

var GrpcServiceObject = common.GrpcServiceObject;
var GrpcServiceObject = commonGrpc.ServiceObject;

function FakeGrpcServiceObject() {
this.calledWith_ = arguments;
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions packages/bigtable/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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() {});
Expand All @@ -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
});
Expand Down
8 changes: 6 additions & 2 deletions packages/bigtable/test/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions packages/bigtable/test/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
});
Expand Down
11 changes: 7 additions & 4 deletions packages/bigtable/test/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down